c

From where to download Turbo or Borland C/C++ compiler+IDE?

Can anybody help me out by telling that from where I can download C/C++ IDE+compiler (whether it's the Turbo C/C++ version or the Borland version)? I mean, I need the previous old traditional version of C/C++, as I need to use it for firmware development. Will appreciate a quick response. ...

Listing all the #defines in a C program

hi, Is it possible to get the list of #defines(both compile time and defined in the source code) used in a C program while execution. Because i am having a project having lot of C source files. Is there any compile time option to get that? __Kanu ...

Direct formula for summing XOR

I have to XOR numbers from 1 to N, does there exist a direct formula for it ? For example if N = 6 then 1^2^3^4^5^6 = 7 I want to do it without using any loop so I need an O(1) formula (if any) ...

Memory layout question

Do these two structs have the same memory layout? (C++) struct A { int x; char y; double z; }; struct B { A a; }; Further can I access x, y, z members if I manually cast an object of this to an A? struct C { A a; int b; }; Thanks in advance. EDIT: What if they were classes instead of structs? ...

Static library auto-discovery and linking

I have the following problem, which seems not to have a nice solution. For example, I have an CLI utility which uses libtiff and libX11. I want to produce two versions of this utility: dynamically linked and statically linked (with as many dependences compiled-in as possible). For dynamic linking everything works as a charm: one need t...

Getting following error "collect2: ld returned 1 exit status"

Hi all, I have created a C source file using the modules from other source files. Suppose the created source file is abc.c .Mine C file compiles fine using the following command. gcc -c abc.c I have compiled each and every source file that are linked to the abc.c .While creating the executable file using the following command: gc...

makefile aliases

Possible Duplicate: makefile aliases Please explain $@ $^ in the makefile below LIBS = -lkernel32 -luser32 -lgdi32 -lopengl32 CFLAGS = -Wall # (This should be the actual list of C files) SRC=$(wildcard '*.c') test: $(SRC) gcc -o $@ $^ $(CFLAGS) $(LIBS) ...

problem in receiving UDP packets

Hi, I'm getting UDP packets from the port continuously. Following is the log from wireshark. How to receive those packets continuously using winsock programming. I tried but I can't able to receive. After recvfrom() call it is not writing into a buffer.Give me idea, how to receive each packet in a buffer and write each packet into to a ...

how to declare variable type, C style in python

Hi, i'm a programming student and my teacher is starting with C to teach us the programming paradigms, he said it's ok if i deliver my homework in python(it's easier and faster for the homeworks). And i would like to have my code to be as close as posible as in plain C. Question is How do i declare data types for variables in python like...

Questions every good C/C++ Developer should be able to answer?

I was going through interview questions tag and found those question are quite useful, so in the same spirit, I am asking this question for C and C++ developers What questions do you think good C and C++ programmers should be able to answer? Looking forward for some amazing responses. Please answer questions too, so that people could ...

Storing a character constant in a character variable...

char ch = 'a'; Here ch is a character variable, so it's size is one byte. 'a' is a character constant,so it's ASCII value will be stored which is 2 byte.But how could it possible to store a 2 byte value in an 1 byte variable ? ...

C String -- Using Equality Operator == for comparing two strings for equality

int main (int argc, **argv) { if (argv[1] == "-hello") printf("True\n"); else printf("False\n"); } # ./myProg -hello False Why? I realize strcmp(argv[1], "-hello") == 0 returns true... but why can't I use the equality operator to compare two C strings? ...

Generic datastructures in C

I'm looking into creating a generic BST. Nothing fancy no COTS, but I'm trying to decide the best way to keep track of the type of the void*. Here's the interface for the nodes: typedef struct { void *data; struct TreeNode *left; struct TreeNode *right; } TreeNode; However, when I write add/remove, I'll need to do compariso...

Hex code for Control+Question Mark?

I am trying to set the special characters for a serial port in a C program. I am able to find all of the hex codes except the code for ^? (Control + Question Mark) used for erase. Required settings: intr = ^C; quit = ^\; erase = ^?; kill = ^X; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; ...

POSIX seekdir() and telldir() behaviour after target folder modification

Hello, consider the following task : 1) read a target directory contents, pass each found dirent structure to some filter function and remember filtered elements somehow for the later processing 2) some time later, iterate through the filtered elements and process them (do some I/O) The most obvious way is to save names of sub-direc...

Standard Error and popen(): how to do it?

I want to open a process from C code, and be able to read its standard output and standard error, while being able to write to its standard input. The closest I get to achieving this is using popen(), but this does not allow you to read the standard error stream. You could add "2>&1" to the command, but this will not make it possible to...

Java's readInt() equivalent in C?

In one side I have a Java client writing ints into its outputstream: int a = 20; dataout.writeInt(a); dataout.flush(); From the other side I have a C server listening the connection: int client = accept(...); How to read the int sent by Java? If I had a Java server, i could easily write: int a = dataIn.readInt(); How to do this in C...

how casting of return value of main() function works ?

Hi, I am using Visual studio 2008. For below code double main() { } I get error: error C3874: return type of 'main' should be 'int' instead of 'double' But if i use below code char main() { } No errors. After running and exiting the output window displays The program '[5856] test2.exe: Native' has exited with code -8...

Fair comparison of fork() Vs Thread

I was having a discussion about the relative cost of fork() Vs thread() for parallelization of a task. We understand the basic differences between processes Vs Thread Thread: Easy to communicate between threads Fast context switching. Processes: Fault talarance. Communicating with parent not a real problem (open a pipe) Communica...

Determine which shared lib calls into my shared

Hello. Am trying to find a way of knowing which shared lib is calling into my shared lib function. The scenario is like this. I have used LD_PRELOAD to override malloc. Inside my malloc I forward the call directly to the real malloc but if the call came from a particular shared lib I want to do some processing before I forward the call...