c

Fetching zend resource without knowing type of the resource

It is possible to fetch the zend resources (zend_fetch_resource) without knowing the type of the fetching resource? If so, how? Note: I am writing PHP extension. ...

typedef stuct problem in C (illegal use of this type as an expression)

Possible Duplicate: typedef stuct problem in C Hello there I am facing I have defined I a structure in a C header file: typedef struct iRecActive{ char iRecSID[32]; unsigned char RecStatus; int curSel; }iRecAcitve_t; but when I use the same structure in another file, the compiler gives some error: error C227...

CUThread lnk2001 error

1>Linking... 1>main.cu.obj : error LNK2001: unresolved external symbol cutWaitForThreads 1>main.cu.obj : error LNK2001: unresolved external symbol cutStartThread I get those errors when trying to compile my project. I have included the cutil64 in linker dependencies, but I can see that's not it. I can't seem to figure out what's wrong w...

gcov does not generate coverage files

I am cross compiliing my executable for coverage using -fprofile-arcs -ftest-coverage flags on a 32 bit machine . And the resulting executable I am running it on target machine which is 64-bit. When I run the executable it does not generate .bb .bbg and .da files. What can be the reason for it. ...

How to retrieve file times with nanosecond precision?

I've just discovered that the stat() call, and the corresponding struct stat, does not contain fields for the file times with precision greater than one second. For setting these times, there are a variety of {f,l}utime{n,}s() functions, but not for getting. How then does obtain these times with nanosecond precision, preferably using PO...

MFC: How to use C++ Global Object in C

Hello there, I have an MFC application in which I have declared a Global Object say "obj" in a file called MiRec2PC.cpp now I want to use this object in a C file. I have used an approach in which I include the header file in which the structure of that particular object is declared. I also use a keyword "extern" with that obj when I u...

How to avoid globals in C?

Hi, as a beginner I read everywhere to avoid excess use of global variables. Well how to do so? My low skill fails. I am ending up passing tons of structures and it is harder to read than using globals. Argh my code is mess any good book/article recommendation that guides trough this problem/application structure design? ...

how to convert a date string to tm_wday in tm structure

Good day all, I have a date string format say like "2010-03-01" and I want to get the "tm_wday" equivalent of it say like Monday, Tuesday ... Could someone give me a hint on how to achieve this in c. Thank you. ...

A newbie question regarding making an executable program.

I’m a student of other discipline. I would like to make an executable program on my own. Suppose the program I would like to make is a small dictionary with a few thousands of words. In the hope of creating such a program in my Windows XP, I collected a compiler called Borland C++ V.5.02. I downloaded some books on C language like Progra...

Alternate way of computing size of a type using pointer arithmetic

Is the following code 100% portable? int a=10; size_t size_of_int = (char *)(&a+1)-(char*)(&a); // No problem here? std::cout<<size_of_int;// or printf("%zu",size_of_int); P.S: The question is only for learning purpose. So please don't give answers like Use sizeof() etc ...

file pointer and using fgets

Hello, gcc 4.4.4 c89 I am reading in a file and in that file I have to do some operation on each line. In a loop I call a 2 functions that pass in this file pointer to perform 2 different operations on the file. However, as I am using fgets to read in a line of that text file. It automatically increments to the next line. So for the ...

Hide terminal, C + GTK

gcc -o program program.c `pkg-config --libs --cflags gtk+-2.0` When I run the program, it show both the GUI and the terminal. How can I hide the terminal? ...

Upload music to iPhone/iPod/... directly without iTunes

Hello, is it possible to program a tool that sends music to iPhone/iPod without putting the songs in iTunes? the tool can work with "iTunes SDK" andit is not attended to go against Apple rules the idea is to not "cache" the songs as iTunes in libraryes, just upload it directly to the iPhone/iPod from file server this help if have musi...

Is the "The UNIX System Interface" chapter of "The C Programming Language" still relevant?

I started reading The C Programming Language and I have now reached "Chapter 8: The UNIX System Interface." Is that chapter worth reading and still relevant as of today? ...

Use gdb console in eclipse

Is there a way how I can access gdb's console in eclipse? I would like to just be able to set breakpoints with the mouse and then use the console for debugging. ...

Automatically touch all files that use a certain #define (#ifdef foo / #endif)

Say you have a C project with tons of files, and tons of configurations managed by usign the -D option in GCC to define some flags. In my particular case, I have loads of files with that kind of stuff: void foo( sometype *x) { do_stuff_with_x(x); #ifdef MY_FLAG do_additional_stuff(x); #endif #ifdef OTHER_FLAG do_some_other_s...

pthreads : allowed number of threads

Hi, I have been working now for few days on a small C program which uses pthreads. I spent more or less all yesterday looking for a deadlock bug, but now I have found out that the problem is not really a deadlock bug. The following piece of code has exactly the same problem. #include <stdlib.h> #include <pthread.h> #include <semaphore....

strlen() function

I have read that use of strlen is more expensive than such testing like this: We have a string x 100 characters long. I think that for (int i = 0; i < strlen(x); i++) is more expensive than this code: for (int i = 0; x[i] != '\0'; i++) Is it true? Maybe the second code will not work in some situation so is it better to use the fi...

finding a number appearing again among numbers stored in a file

Hello, Say, i have 10 billions of numbers stored in a file. How would i find the number that has already appeared once previously? Well i can't just populate billions of number at a stretch in array and then keep a simple nested loop to check if the number has appeared previously. How would you approach this problem? Thanks in advance...

Compiling make based project with MSVC?

In OSX, I'm used to simply doing ./configure make But in MSVC when I do Project from existing code and try to compile I get hundreds of errors. I'm trying to compile GLU from the Mesa3D library. How could I do this in MSVC? Thanks ...