Difference between LPVOID and void*
Can I use void* instead of LPVOID in c? Or LPVOID perform some special functionality then void* ...
Can I use void* instead of LPVOID in c? Or LPVOID perform some special functionality then void* ...
i need to count digits from a float number and keep the number. i can use scanf for %f or %c but not %s, and i can use getchar(). i can use getchar but ill loose the number ...
My code is as follows: #include <stdio.h> struct MyData { int id; char msg[255]; }; int main ( int argc, const char * argv[] ) { struct MyData item; item.id = 3; item.msg = "something else"; printf("Msg: %d", item.msg); return 0; } I get an error of incompatible types in assignment on the line: item.msg ...
Is there a Windows native API analogous to pthread_cancel, pthread_testcancel etc? If not, how can we simulate cancelling of one thread from another using the pthread_cancel mechanism in Windows? ...
Windows Mutex seems to allow an acquired lock to be acquired again (recursively) if the thread currently owning the lock tries to acquire it. But, posix based pthread locks don't allow such a behaviour. Is there any compile time macro or any settings which can make the windows mutex behave in the same way as the pthread mutex? ...
Hi, The following program does not work as I intended. #include <string.h> #include <stdio.h> int main() { const char *c = "abcdef"; // prints 'f' as expected printf("%c\n", c[5]); // comparison fails, does not print "yes" if (c[5] == 'f') printf("yes"); return 0; } How can I compare a character in ...
I have installed visual studio 2008 and i want to create some simple applications using C language. I do this by creating c++ console applications but i want the compiler to work for C not C++. Any way to accomplish this or i need another compiler if i want to deal with C? ...
Introduction Hello folks, I recently learned to program in C! (This was a huge step for me, since C++ was the first language, I had contact with and scared me off for nearly 10 years.) Coming from a mostly OO background (Java + C#), this was a very nice paradigm shift. I love C. It's such a beautiful language. What surprised me the mos...
Question is: Find the sum of all the primes below 2 million. I pretty much did the Sieve of Erastothenes thing, and the program below seems to work for small number i.e. define LIMIT as 10L produces 17 as answer. I submitted 1179908154 as the answer, as produced by the following program, and it was incorrect. Please help pointing out ...
int *i; *i=123; ...
Hi, I have got a structure and in it a pointer to a 2D array. But when I try to assign an actual 2D array to that pointer I do not succeed - compiler says that my pointer is a pointer to a 1D array. Here's my code: typedef GLfloat Vertex2f[2]; typedef GLfloat TextureCoordinate[2]; typedef struct { GLuint texture_name; // OpenGL...
What is wrong with addAtBegin? The list seems to be correct after assigning the newly created node to start, but when control returns to main, the new value is not saved. typedef struct node { int data; struct node *link; }node; node* createList(int data) { node *tempNode=(node*)malloc(sizeof(node)); tempNode->data=data...
Hi everyone, Does anyone know how to calculate the error of quantizing from 16bit to 8bit? I have looked at the Wikipedia article about Quantization, but it doesn't explain this. Can anyone explain how it is done? Lots of love, Louise Update: My function looks like this. unsigned char quantize(double d, double max) { return (unsi...
I have some piece of code that behaves differently under Mac OSX and Linux (Ubuntu, Fedora, ...). This is regarding type casting in arithmetic operations within printf statements. The code is compiled with gcc/g++. The following #include <stdio.h> int main () { float days = (float) (153*86400) / 86400.0; printf ("%f\n", days); fl...
Hi I have a problem with my function, which responsible for contact between client and server: #define MAX 1024 void connection(int sock) { char buffer[MAX]; int newsock; int n; int r; if(write(sock,"Hello!\n", 6) < 0) { perror("Error: "); } do { if(write(sock, "\n> ",3) < 0) {...
in gcc, i want to do a 128 bits xor with 2 C variables, via asm code: how? asm ( "movdqa %1, %%xmm1;" "movdqa %0, %%xmm0;" "pxor %%xmm1,%%xmm0;" "movdqa %%xmm0, %0;" :"=x"(buff) /* output operand */ :"x"(bu), "x"(buff) :"%xmm0","%xmm1" ); but i have a Segmentation fault error; this is the objdump out...
i come from a php background and am studying this page http://cocoadevcentral.com/articles/000081.php before i step foot into some of the harder stuff in regards to objective-c if i type something like this typedef struct { int lengthInSeconds; int yearRecorded; } Song; and when setting a function or a variable of type Song, what...
Hello, I am using "ExuberantCtags" also known as "ctags -e", also known as just "etags" and I am trying to understand the TAGS file format which is generated by the etags command, in particular I want to understand line #2 of the TAGS file. Wikipedia says that line #2 is described like this: {src_file},{size_of_tag_definition_data_in...
I'm on a 64bit platform, so all memory adrs are 8 bytes. So to get an estimate of the memory usage of an array, should I add 8 bytes to the sizeof(DATATYPE) for each entry in the array. Example: short unsigned int *ary = new short unsigned int[1000000]; //length 1mio //sizeof(short unsinged int) = 2bytes //sizeof(short unsinged int*)...
According to this stack overflow answer, the "_t" postfix on type names is reserved in C. When using typedef to create a new opaque type, I'm used to having some sort of indication in the name that this is a type. Normally I would go with something like hashmap_t but now I need something else. Is there any standard naming scheme for typ...