c

rename a file in c

I was just wondering how could i rename a file on unix platform using a c program without using the standard rename function.any ideas? rename a file in c ...

Opening file in another directory in C

How is this achieved? I want to use pFile = fopen( file, "rb" ); Where file is a char, string or long containing the literal text containing a local path to a binary file C:\Documents and Settings\Supernovah\Desktop\Supernovah.bin but of course that crashes. I am also interested in how to recur over the current directory in a port...

General printing raster and/or vector images

Hi, I'm looking for some API for printing. Basically what I want to achieve is to print set of pixels(monochromatic bitmap which I store in memory) onto the generic paper format (A4,A5..etc.). What I think that would be minimum API is: printer devices list printer buffer where I could send my in-memory pixmap (ex. like winXP printer...

How do I require Gosu with IronRuby?

I tried to require Gosu's .so file, but it said something about "expecting assembly", I assumed that IronRuby will support library files which aren't written in dot net, may anybody help me please? ...

What's the difference between *d++ and (*d)++ in C?

as in the title, what's the difference because these two seem to get me the same results? ...

Embedded programming books

What embedded programming/design books would you suggest? With embedded I mean near to hardware programming in ASM and C/C++. I'm looking something related to best practices in embedded programming/design. Operation system could be Linux, Real Time Linux or any other RTOS. ...

C dynamic allocation for a grid when rows are not known

I am trying to allocate a array of char*'s in C. I know the number of columns in advance, but not the rows and I want to allocate the rows as and when needed. I tried to use: char *(*data)[NUMCOLS]; //declare data as pointer to array NUMCOLS of pointer to char data = malloc(sizeof(char*)); now, the above line should allocate for dat...

How to cast an int's address to char pointer in C?

Hi all, Currently the below code gives me a warning when i try to compile it: int z; char *w; w = How can i cast &z properly so that w stores the pointer to z's address? ...

What does this notation mean in C?

int *w; int **d; d = &w; What does the **d store exactly? ...

Bitfield masks in C

Is there a portable way in C to find out the mask for a bit field at compile time? Ideally, I'd like to be able to atomically clear a field like this: struct Reference { unsigned age : 3; unsigned marked : 1; unsigned references : 4; }; struct Reference myRef; __sync_and_and_fetch(&myRef, age, ~AGE_MASK); Otherwise I hav...

Why is MSVC throwing a tantrum compiling a macro while G++ is all about zen?

Under MSVC 9.0, this fails. Under g++ this compiles. If we take out the macro then the non-macro version 76-79 compiles. Any ideas? 03: #include <iostream> 04: #include <sstream> 67: #define MAKESTRING(msg, v) \ 68: do { \ 69: std::ostringstream s; \ 70: s << msg; \ 71: v = s.str(); \ 72: } whil...

Good Text Tokenizer Library

What is a good open source C word tokenizer library? I am look for something like Tokenize("there are three apples. One is orange, the other is blue," " and, finally, the last is yellow!") with the output not containing any punctuation. ...

Getting "conflicting types for function" in C, why?

Hello, I'm using the below code: char dest[5]; char src[5] = "test"; printf("String: %s\n", do_something(dest, src)); char *do_something(char *dest, const char *src) { return dest; } The implementation of do_something is not important here. When I try to compile the above I get these two exception: "error: conflicting types for 'd...

How to declare a C Array as a property of an Objective-C object?

I'm having trouble declaring a C Array as an Objective-C Property (You know @property, and @synthesize so I can use dot syntax)...Its just a 3 dimensional int array.. ...

Debug error in NetBeans

I am running a C program in NetBeans (cygwin on windows). Generally for all C programs I have run in the past, while debugging, it stops and shows the line number of segmentation fault. But for this particular program, it does not show the line number and just stops and in the output tab, it shows prog stopped by SIGSEGV. I have tried co...

Can I use scanf to capture a directive with a width specified by a variable?

I have the following code: scanf(" %Xs %Ys", buf1, buf2); Where X and Y should be integers. The problem is that the values for X and Y are compile-time constants, and even if I wanted to hard-code the values into the format string, I can't, because I don't know the values. In printf, you can send a width variable along with the argume...

Max size of function stack in C (gcc)

I want to know what is the maximum number of (recursive)function calls allowed in gcc C. I have a program which can take stack depth of 400000 function calls each with size of around 200 bytes (so around 80 MB). How can I increase the maximum depth? ...

Why would you ever want to allocate memory on the heap rather than the stack?

Possible Duplicate: When is it best to use a Stack instead of a Heap and vice versa? I've read a few of the other questions regarding the heap vs stack, but they seem to focus more on what the heap/stack do rather than why you would use them. It seems to me that stack allocation would almost always be preferred since it is quic...

Enumerating Permutations of a set of subsets

I have sets S1 = {s11,s12,s13), S2 = {s21,s22,s23) and so on till SN.I need to generate all the permutations consisting elements of S1,S2..SN.. such that there is only 1 element from each of the sets. For eg: S1 = {a,b,c} S2 = {d,e,f} S3 = {g,h,i} My permuations would be: {a,d,g}, {a,d,h}, {a,d,i}, {a,e,g}, {a,e,h}.... How would ...

Are c styled strings safe?

In c/c++ some people use c-styled strings like: char *str = "This is a c-styled string"; My question is is this safe? The way I see it is they created a char pointer that points to the first letter of a const array of chars, but can't some other thing eg another variable overwrite a portion of the char array in the memory? Thus causin...