c

C: Question about Beej's networking guide... Is there an assumption here?

I was just going through the Networking Guide by Beej and am curious about this part of the code (specifically marked with "From here" and "To here"): // main loop for(;;) { read_fds = master; // copy it if (select(fdmax+1, &read_fds, NULL, NULL, NULL) == -1) { perror("select"); exit(4); ...

Texture mapping in OpenGL (with SOIL)

I'm having trouble getting a texture loaded with SOIL to show up properly on this quad. In case it's not clear, I'm just writing up a little 2D sprite engine, and this is the rendering portion (needs a bit of optimization without a doubt). I haven't done any OpenGL in a couple months, and I'm admittedly quite rusty. #include <OpenGL/Ope...

How to implement a leveled debug system?

Hi, by design, in the environment I'm working right now I can't use a debugger to try to detect bugs, so pretty much always when I need to debug a functionality I end up outputting some info. To do that I've done the following: #ifdef DEBUG #define printd(x) printf x #else #define printd(x) #endif So when I need to print some...

How to free() a malloc()'d structured correctly?

Hi! i have a structure malloc()'d, and after using them, i want to free() it, but my program freezes out here. Can anyone tell me, what i am doing wrong? Here is my code: struct data { char *filename; char *size; }; //primarypcs is a long type variable struct data *primary = (struct data *)malloc( primarypcs * sizeof( stru...

C: Is there something better than a FIFO Queue implementation for this requirement?

In one of my programs, there are multiple clients and each client has its own buffer. In an infinite loop, I check if any of the client has any data to be written to disk. If it does, then I do the same and continue. Now, because the client writes data that is not really in my control (result of some computations), I need a dynamic buf...

convert big endian to little endian in C [without using provided func]

I need to write a function to convert big endian to little endian in C. I can not use any library function. ...

C puzzle: Output of printf should be '5' always

Hi, I found this puzzle in a C aptitude paper. void change() { //write something in this function so that output of printf in main function //should always give 5.you can't change the main function } int main() { int i = 5; change(); i = 10; printf("%d", i); return 0; } Any solutions.? ...

Is it OK to free void* ?

struct foo { int a; int b; }; void* p = (void*)malloc(sizeof(struct foo)); ((foo*)p)->a;//do something. free(p);//Is this safe? thanks! ...

Error modes for OpenCV

Hello, I am using OpenCV 1 to do some image processing, and am confused about the cvSetErrMode function (which is part of CxCore). OpenCV has three error modes. Leaf: The program is terminated after the error handler is called. Parent: The program is not terminated, but the error handler is called. Silent: Similar to Parent mode...

configure gdb compiler in netbeans6.8 in linux platform

hi guys, i have a small problem.can anybody say how we can configure gdb compiler in netbeans6.8 in linux platform. thanks in advance. ...

Static function access in other files

Hi, Is there any chance that Static function can be assessed outside the file scope. ? ...

Playing an incoming videostream using rtp and gstreamer

can i set the object to play the incoming video using g_object_set? i set the object like this "g_object_set (G_OBJECT (rtpbin), "destinations","host", NULL);" but not playing the video. pls help me to solve this problem. ...

Default flags for gcc compiler in Eclipse

I want all my C programs to be compiled with the options -Wall -pedantic -ansi by default. Is there a way to have Eclipse add these flags to the compiler command by default for all projects? ...

Error working with structs and pointer arrays: incompatible types in assignment

#define STRMAX 50 struct Person { char sName[STRMAX]; int iAge; }; typedef struct Person PERSON; int main() { PERSON *personen[1]; personen[0]->sName = "Pieter"; personen[0]->iAge = 18; return 0; } This code generates an error on personen[0]->sName = "Pieter"; saying incompatible types in assignment. Why? ...

Detect removable drive (e.g. USB flash drive) C/C++

How can I detect when a removable disk drive is (dis)connected to the system? How to get the mount path (for Linux) and the drive letter (for windows)? EDIT: Is there a way to detect the currently connected devices? ...

Is there an easier way to type and compile C on Mac OS X?

I've just started learning C on Mac OS X. I have downloaded Xcode too. So far, I have been typing my apps into TextEdit, and then using the Terminal to locate my apps and compile them using gcc hello.c etc. Is there an easier way (using Xcode perhaps?) to type my code into some form of IDE, and then automate the compiling with a 'compi...

Help track down segfault in "probe" (?) on mingw

Hi! I use MinGW-5.1.6 and MSYS-1.0.11 to build a static libgmp, and then to build some custom libs and programs which use libgmp. Both gmp and the custom things are built using C(XX)FLAGS="-g -ggdb" ./configure. Gmp's make check runs fine. Everything is statically linked (same effect was seen on dynamic linked libgmp). Now when trying ...

What does "request for member '*******' in something not a structure or union" mean?

Is there an easy explanation for what this error means? request for member '*******' in something not a structure or union I've encountered it several times in the time that I've been learning C, but I haven't got a clue as to what it means. ...

Any Framework to build a code checking website(like SPOJ) ?

Hi guys, My col is planning to conduct a online coding competition.. Im now looking for a framework that checkes user's code and returns the appropriate result.. Only C,C++ support is enough.. -Dinesh ...

Is it possible to call a C function, given its name as a string?

I saw this question in one of the C puzzles!! Is this really possible? How can I call a function, given its name as a string? is it possible to use string that is read with scanf be used directly to call a function? i already have thought of if(strcmp(str,"string"))then call the function. but is there any other approach? ...