c

fgets() linux vs mac

Does fgets on a mac read until a carriage return '\r' or does it also depend on the new line '\n'? Reason is I am using fgets to read a file a line at a time. However if it is run on a mac file with only '\r' for the line ending it fails to do what I want. (run in linux) I don't want to be writing library type functions to deal with cr...

bus error in simple Mac OSX C program

I am writing a simple C program to create a twelve tone matrix. The code compiles, but I get run time error 'Bus Error'. In the debugger it says EXC_BAD_ACCESS. int main () { int j,k,l; int twelve[13][13]; void mat(int twelve[13][13]); printf("input original tone row \n"); for(j=0;j<=11;j++) { scanf("%2i...

Contributing to open source projects

Hi, I am relatively new to programming, but I enjoy it a lot. I was told that contributing to opensource projects is a good way to learn a lot more. Anywyas, I was wondering if anybody knew what projects I could contribute to--even if I play a small role any experience would be appreciated. My background is C and Java. I prefer workin...

Why do C languages require parens around a simple condition in an if statement?

It sounds stupid, but over the years I haven't been able to come up with a use case that would require this. A quick google search didn't reveal anything worthwhile. From memory there was a use case mentioned by Bjarne Stroustrup but i can't find a reference to it. So why can't you have this in C languages: int val = 0; if val doSom...

42 passed to TerminateProcess, sometimes GetExitCodeProcess returns 0

After I get a handle returned by CreateProcess, I call TerminateProcess, passing 42 for the process exit code. Then, I use WaitForSingleObject for the process to terminate, and finally I call GetExitCodeProcess. None of the function calls report errors. The child process is an infinite loop and does not terminate on its own. The proble...

Using C/C++ to efficiently de-serialize a string comprised of floats, tokens and blank lines

I have large strings that resemble the following... some_text_token 24.325973 -20.638823 -1.964366 0.753947 -1.290811 -3.547422 0.813014 -3.547227 0.472015 3.723311 -0.719116 3.676793 other_text_token 24.325973 20.638823 -1.964366 0.753947 -1.290811 -3.547422 -1.996611 -2.877422 0.813014 -3.547227 1.63236...

GCC dies trying to compile 64bit code on OSX 10.6

I have a brand-new off-the-cd OSX 10.6 installation. I'd now like to compile the following trivial C program as a 64bit binary: #include <stdio.h> int main() { printf("hello world"); return 0; } I invoke gcc as follows: gcc -m64 hello.c However, this fails with the following error: Undefined symbols: "___gxx_perso...

c scanf question

Why do you require ampersand (&) in scanf. What will be the output or type of error (compile or runtime ) in the following c code? #include <stdio.h> void main() { int a; printf("enter integer"); scanf("%d",a); } ...

why is this code causing runtime error?

#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char *a = "Hello "; const char *b = "World"; printf("%s", strcat(a, b)); system("PAUSE"); return EXIT_SUCCESS; } ...

Rewrite equation in c

Gain = 255 / (1 - 10 ^ ((Refblack-Refwhite) * 0.002/0.6) ^ (Dispgamma/1.7)) Is that a computer language, it looks like c but exclusive or floats doesnt compute. Can anybody convert that to c? thanks ...

Access BIOS data from Windows-PE

Hello. Is it possible to access BIOS data from Windows PE? Specifically I'd like to be able to write a console app in C which returns the serial number, much like "Get-WmiObject Win32_BIOS | Select SerialNumber" would in PowerShell. Is there any way to access BIOS memory locations directly, or is there any calls that can be used to acc...

read and write to same socket (TCP) using select

We're writing a client and a server to do (what I thought was) pretty simple network communications. Mulitple clients connect to the server which then is supposed to send the data back to all other clients. The server just sits in a blocking select loop waiting for traffic, and when it comes, sends the data to the other clients. This ...

C/C++ library for VTK IO

I have a simulation in C++ which generates huge amount of data. Right now I am using MATLAB libraries to save the results as a .mat file, but eventually I will be needing an open source binary format. I don't want to implement my own binary format and ASCII is not an option. I heard that VTK provides .vtk binary file format for saving 3d...

Write C as s-expressions.

I want to write C in s-expressions and use compile-time macros. Does anybody know of anything that does this? It should translate the s-expressions into standard C. ...

Python C-API Making len(...) work with extension class

When creating a class in Python, I can simply make a def __len__(self): method to make the len(InstanceOfMyClass) work, however I can't find out how to do this with an extension class via the C-API. I tried adding a __len__ method, but that appears to not work {"__len__",(PyCFunction)&TestClass_GetLen,METH_NOARGS,""}, Python test cod...

Moving libraries and headers

Hi, I have some c code which provides libfoo.so and libfoo.a along with the header file foo.h. A large number of clients currently use these libraries from /old_location/lib and /old_location/include directories which is where they are disted. Now I want to move this code to /new_location. Yet I am not in a position to inform the clien...

What is a good resource to read about stack/heap and symbol table concepts?

Please suggest some website or some book that deals with these topics in really good detail. I need to have a better understanding of these concepts (in reference to C++): stack and heaps symbol tables implementation of scope rules implementation of function calls ...

Getting the source address of an incoming socket connection

i have a server with a incoming socket from a client. i need the get the ip addr of the remote client. tried searing google for in_addr but its a bit troublesome. any suggestions? thanks ...

C/C++ HTTP library, that handles only the logic?

I am looking for an HTTP library for C/C++, that handles only the protocol logic, instead of the actual transport mechanism. Libraries I've came across tend to incoperate the entire communication process, which is not what I need. However, I'm looking for something that's more than merely an HTTP parser. Ideally it would also take care ...

Effect of placement of deference operator vs whitespace in C

Possible Duplicates: what is the difference between int i and int i? what is the difference between const int*, const int * const, int const * What is the difference between char* getInput(); and char *getInput(); ...