c

Is FindFirstChangeNotification the best API to use for file system change notification on windows?

I'm new to windows programming and I'm trying to get notified of all changes to the file system (similar to the information that FileMon from SysInternals displays, but via an API). Is a FindFirstChangeNotification for each (non-network, non-substed) drive my best bet or are there other more suitable C/C++ APIs? ...

How do you spawn another process in C?

How do you run an external program and pass it command line parameters using C? If you have to use operating system API, include a solution for Windows, Mac, and Linux. ...

Pointer Manipulation Help

Hi everyone, I am trying to build a function in C/c++ to sort an array and replace each value with its "score" or rank. It takes in a double pointer array to an array of ints, and sorts the double pointers based on the dereferenced value of the integers. I have tried quite a few times to make it work, but cant get it down. Once again,...

What Comes After The %?

I've searched for this a little but I have not gotten a particularly straight answer. In C (and I guess C++), how do you determine what comes after the % when using printf?. For example: double radius = 1.0; double area = 0.0; area = calculateArea( radius ); printf( "%10.1f %10.2\n", radius, area ); I took this example straight fr...

Ruby blocks/Java closures in C

I've been trying to understand how Ruby blocks work, and to do that I've been trying to implement them in C (^_^). One easy way to implement closures is to pass a void* to the enclosing stack to the closure/function but Ruby blocks also seem to handle returns and break statements from the scope that uses the block. loop do break i if...

what is the difference between #include <filename> and #include "filename"

In the C and C++ programming languages, what is the difference between using angle brackets and using quotes in an include statement. #include <filename> #include "filename" ...

What's a 'null defined macro'?

I'm learning objective-C and Cocoa. In the Apple tutorial I'm working through there's a side note that says: IBOutlet is a null-defined macro, which the C preprocessor removes at compile time. I'm curious - what's a null-defined macro? Cheers Ben ...

Implementing a log watcher

I wondering how in C/C++ you can implement a program (similar to tail -f) that watches for new lines added to a log file and then process them? ...

memset() causing data abort

I'm getting some strange, intermittent, data aborts (< 5% of the time) in some of my code, when calling memset. The problem is that is usually doesn't happen unless the code is running for a couple days, so it's hard to catch it in the act. I'm using the following code: char *msg = (char*)malloc(sizeof(char)*2048); char *temp = (char*...

What are the major differences between ANSI C and K&R C?

The Wikipedia article on ANSI C says: One of the aims of the ANSI C standardization process was to produce a superset of K&R C (the first published standard), incorporating many of the unofficial features subsequently introduced. However, the standards committee also included several new features, such as function prototypes (borrowe...

What is the best way to communicate with a SQL server?

I am going to be using c/c++, and would like to know the best way to talk to a MySQL server. Should I use the library that comes with the server installation? Are they any good libraries I should consider other than the official one? ...

How Does One Sum Dimensions of an Array Specified at Run-Time?

Hi all, I am working on a function to establish the entropy of a distribution. It uses a copula, if any are familiar with that. I need to sum up the values in the array based on which dimensions are "cared about." Example: Consider the following example... Dimension 0 (across) _ _ _ _ _ _ _ _ _ _ _ _ _ |_ 0 _|_ 0 _|_ 0 _|_ 2 _| D...

What's a good linux C/C++ IDE for a low-res screen?

I recently bought an Asus Eee PC 901, on which I am running Ubuntu linux. I was mucking around in C on my old (larger) laptop, and I want to continue to do so on the Eee. However, Anjuta - the IDE that I was using - is not very usable with the Eee's resolution of 1024x600. What with the status pane at the bottom, and the giant toolbar...

(C) What is the difference between ++i and i++

In C, what is the difference between using ++i and i++. And which should be used in the incrementation block of a for loop? ...

Why does my "3n+1 problem" program not compile ?

I'm trying to solve the 3n+1 problem and I have a for loop that looks like this: for(int i = low; i <= high; ++i) { res = runalg(i); if (res > highestres) { highestres = res; } } Unfortunately I'm getting this error when I try to ...

Is there a performance difference between i++ and ++i in C?

Is there a performance difference between i++ and ++i if the resulting value is not used? ...

C Memory Management

I've always heard that in C you have to really watch how you manage memory. And I'm still beginning to learn C, but thus far, I have not had to do any memory managing related activities at all.. I always imagined having to release variables and do all sorts of ugly things. But this doesn't seem to be the case. Can someone show me (with ...

Help with sigprocmask()

I haven't completely understood how to use sigprocmask(). Particularly how the set and oldset in its syntax work and how to use them. int sigprocmask(int how, const sigset_t *set, sigset_t *oldset); Please explain with an example used to block, say SIGUSR1 for a few seconds and then unblock and handle it. ...

What are the best practices when using SWIG with C#?

Has anybody out there used the SWIG library with C#? If you have, what pitfalls did you find and what is the best way to use the library? I am thinking about using it as a wrapper for a program that was written in C and I want to wrap the header files where I can use them in my .NET application. Edit: Some clarification on target OS'...

stdbool.h c++

In a project I am interfacing between c++ and a c library that uses stdbool.h defined as such. #ifndef _STDBOOL_H #define _STDBOOL_H /* C99 Boolean types for compilers without C99 support */ /* */ #if !defined(__cplusplus) #if !defined(__GNUC__) /* _Bool builtin type is included in GCC */ typedef enum { _Bool_must_promote_to_int = -1...