c

What does an upside down question mark mean in the output in C?

Hi, I get an upside down question mark as an output from of of my function, what does it mean exactly? ...

Is a makefile basically the same thing as a batch file?

I know all about batch files and made them before, but I'm unclear on what a makefile is. It looks like a batch file. What are the similarities and diffferences? ...

malloc vs mmap in C

Hi, I built two programs, one using malloc and other one using mmap. The execution time using mmap is much less than using malloc. I know for example that when you're using mmap you avoid read/writes calls to the system. And the memory access are less. But are there any other reasons for the advantages when using mmap over malloc? T...

Understanding and doing Code Injection in C

I am a bit confused in the idea of code injection in C. If somebody could explain it and show how its done I would appreciate it. So lets say in C you have some Char array of size 512 which is being written to the contents of a socket of length 1024, and that char array now holds some sort of code but only half of what was written. Ho...

Opening a file and outputting in C

I'm using XCode and I'm trying to open a file that gets passed as a command line argument, and output the number of lines that gets passed as a command line argument of that file, to the console in C. In XCode, my arguments are "test.rtf", and "5". My rtf looks like: line 1 test line 2 test line 3 test line 4 test line 5 test line 6 t...

GCC: Force a function call after every instruction (for multithreaded testing)?

Hi, I'm trying to test a rather threading-sensitive area in my program and was wondering if there's a way to force gcc to insert a call after every instruction it emits so that I can manually yield to a different thread? Thanks, Robert ...

Good C IDE for Mac?

I've just started a job where I'm programming in C on a Mac, which is my first experience using a Mac for development. For now I'm using XCode as my editor, then using make/gcc/svn at the command line for compiling and source control. Is there a good, full featured IDE out there for Macs that will compile C code (something comparable to...

C99 backward compatibility

I'm used to old-style C and and have just recently started to explore c99 features. I've just one question: Will my program compile successfully if I use c99 in my program, the c99 flag with gcc and link it with prior c99 libraries? So, should I stick to old C89 or evolve? Thanks. ...

Serial programming: measuring time between characters

I am sending/receiving data over a serial line in Linux and I would like to find the delay between characters. Modbus uses a 3.5 character delay to detect message frame boundaries. If there is more than a 1.5 character delay, the message frame is declared incomplete. I'm writing a quick program in C which is basically fd = open(MODEM...

C Problems and Solutions

I'm looking for a series of C problems (with solutions) that I can use to build my C skills. I already understand the basics of the language, the syntax, and the semantics. I am looking for a series of problems that will help me hone my skills, not a set of simple questions that you'd see in an introductory programming class. ...

C macro processing

Hy. I'm thinking about best way to write C define processor that would be able to handle macros.Unfortunately nothing intelligent comes to my mind. It should behave exactly like one in C, so it handles expressions like this: #define max(a, b) (a > b ? a : b) printf("%d\n", max(a, b)); Or this: #define F 10 #define max(a, b) (a > b ...

Warning/error from ALSA's pcm_min.c example. Possible problem?

Dear developers, When I compile ALSA's pcm_min.c example with gcc -Wall -lasound pcm_min.c -o pcm_min Everything is fine, but running it, I get the white noise as expected, but I also get this warning/error: Short write (expected 16384, wrote 7616) Which comes from the last if-statement. #include <alsa/asoundlib.h> static char *...

JNA ByteBuffer statvfs

I am trying to get the free space on the / folder using statvfs call from java, I have check the size of statvfs struct from c it shows 44 bytes, I have allocated a byte buffer using java.nio.ByteBuffer.allocateDirect 44 bytes, and it's order is set to 44 bytes. when i call statvfs i get a return value of 0, so i am assuming call is suc...

Determining Stack Space with Visual Studio

I'm programming in C in Visual Studio 2005. I have a multi-threaded program, but that's not especially important here. How can I determine (approximately) how much stack space my threads use? The technique I was planning to use is setting the stack memory to some predetermined value, say 0xDEADBEEF, running the program for a long time...

C program to compare integers without using logical operators?

Can anyone tell me how to write a C program to compare numbers(including negative numbers) without using logical operators? ...

Creating a FILE * stream that results in a string

I'm looking for a way to pass in a FILE * to some function so that the function can write to it with fprintf. This is easy if I want the output to turn up in an actual file on disk, say. But what I'd like instead is to get all the output as a string (char *). The kind of API I'd like is: /** Create a FILE object that will direct writ...

A language that doesn't use 'C' ?

Just curious. I may be wrong, but as far as I know, most languages are created using 'C' sources. For example: perl , php , python, java(?), go ... Is there any language that doesn't use C as a low level interpreter/compiler ? (fortran ?) ...

Is there a C header parser tool for wrapper generation like gccxml?

I need to write a few c header wrappers for a new programming language and would like something like gccxml but without the full dependency on gcc and the problems it gives on a windows system. Just needs to read C not C++. Output in any format is okay as long it is fully documented. Need it for Curl, SQLite, GTK2, SDL, OpenGL, Win32 A...

How to create a symbol table?

Can I use malloc to add symbol table entries? How do I traverse the table to check if something is already there? ...

How do I wait for PID X to exit if X is not a child process?

using c how do I wait for PID X to exit when it is not a child of my current process? Kill(pid, SIGTERM); waitpid(pid,NULL,0); The above does not work as 'pid' is not a child process. ...