Advanced C learning
Can anyone recommend me some book or learning source about advanced C programing especially GUI, database and network. Thanks a lot. ...
Can anyone recommend me some book or learning source about advanced C programing especially GUI, database and network. Thanks a lot. ...
Just curious, I was told that with dll files, you can make modifications to the dll without recompiling the whole application that uses it. On the other hand .lib files need to be compiled so the code can linked to the application as one. So I know that the .lib files are turned into machine code. but what about the dll's ?? Are they t...
I've been at this for a while now and it really puzzles me. This is a very distilled code fragment that reproduces the problem: uint8_t dataz[] = { 1, 2, 3, 4, 5, 6 }; struct mystruct { uint8_t dummy1[1]; uint16_t very_important_data; uint8_t dummy2[3]; } *mystruct = (void *) dataz; printf("%x\n", mystruct -> very_import...
Hello, Lately I've realized that one must be good at handling (parsing) text. It may be from as simple as interpreting the HTTP response or reading a settings file (*.ini or *.xml or *.json) to as hard as writing a compiler or regex engine. I agree that now we have library functions/methods for interpreting popular formats of text. But...
I have been experimenting with async Linux network sockets (aio_read et al in aio.h/librt), and one thing i have been trying to find out is whether these are zero-copy or not. Pretty much all i have read so far discusses file I/O, whereas its network I/O i am interested in. AIO is a bit of a pain to use and i suspect is non-portable, so...
Probably an extremely simple answer to this extremely simple question: I'm reading "C Primer Plus" by Pratta and he keeps using the example while (scanf("%d", &num) == 1)... Is the == 1 really necessary? It seems like one could just write: while (scanf("%d", &num)) It seems like the equality test is unnecessary since scanf returns...
Why this dont work: int size = 2; int array[size]; int main() { return 0; } It says the error: array bound is not an integer constant And this work: int size = 2; int main() { int array[size]; return 0; } Anyone knows the reason??' thanks ...
Hello to everyone!! I am trying to print the MAC address by using ether_ntoa. When i try to do printf("MAC (src): %s\n",ether_ntoa((struct ether_addr *)&eheader->ether_shost)); I get a segmentation fault, so I have come up with two different approaches: This is the snippet code nº1: struct ether_header *eheader; char *p; ... p = et...
I am just trying to further understand extern C functions. According to my knowledge, an extern C function is always a function you are trying call from an application that has already been compiled. Either a executable, static or dynamic library. extern "C" { HRESULT CreateDevice(); typedef HRESULT (*CREATEDEVICE)(); HRESU...
lets say i have a bunch of bins, each of which holds a range of numbers. an example is: bin 1: 0-8 bin 2: 9-16 bin 3: 17-24 etc is there a way to use a switch statement to figure out which bin a number belongs to? i'm trying to figure out how to make cases reflect that a number is within a range, but they don't seem to be 'constant ex...
I have polygon chains similar to the following... ...given the chain in the image, how would I go about calculating a chain that defines the same shape but without crossing paths? Specifically, in the case of the image's input chain, the result I want looks like this: A1, A2, Intersect between A2 and A3, Intersect between A3 and A4,...
#include <iostream> typedef struct _person { std::string name; unsigned int age; }Person; int main() { Person *pMe = new Person; pMe->age = 10; pMe->name = "Larson"; std::cout << "Me " << (*pMe).age << " " << (*pMe).name.c_str() << std::endl; return 0; } Consider the above code. The members of the struct...
Hi, Is it the correct way of allocating memory to a char*. char* sides ="5"; char* tempSides; tempSides = (char*)malloc(strlen(inSides) * sizeof(char)); ...
I'd like to statistically profile my C code at the instruction level. I need to know how many additions, multiplications, divisions, etc I'm performing. This is not your usual run of the mill code profiling requirement. I'm an algorithm developer and I want to estimate the cost of converting my code to hardware implementations. For this...
hi i am a student and just start learning low level c programming.i tried to understand read() and write() methods with this program. #include <unistd.h> #include <stdlib.h> main() { char *st; st=calloc(sizeof(char),2);//allocate memory for 2 char read(0,st,2); write(1,st,2); } i was expecting that it would give segmen...
I'm getting the following error and can't for the life of me figure out what I'm doing wrong. $ gcc main.c -o main Undefined symbols: "_wtf", referenced from: _main in ccu2Qr2V.o ld: symbol(s) not found collect2: ld returned 1 exit status main.c: #include <stdio.h> #include "wtf.h" main(){ wtf(); } wtf.h: void wtf();...
I have written a multithreaded program and the thread was implemented in such a way that as to fork a child process and through this child process several modules were loaded. During my testing at one time, i find process (running in solaris platform) aborts one time and it creates a segementation fault. On going through the dump file, ...
I am trying to find the location of an element in the array. I have tried to use this code i generated for(i=0;i<10;i++) { if (strcmp(temp[0],varptr[i])==0) j=i; } varptr is a pointer which points to array var[11][10] and it is by the definition *varptr[11][10]. I have assigned strings to var[i] and i want to get the "i" n...
I am developing a control device with an embedded webserver. The webserver provides a control interface to any web browser that requests it (from Windows browsers, Mac browsers, iPhone android etc). The problem I am having is with a general way of generically knowing how to access the device. i.e. what address to type in the web browser...
I have just started learning pthreads API and I am following the tutorial here However, in an example program of pthread_create, the sample program creates a long variable and passes its value, typecasted as void*. In the thread entry function, it dereferences it just like a long. Is this legit? I understand if I pass the address of v...