c

How to be informed when gtk.paned slider's position changed?

I wanna the hpaned to remember the slider position, then I need to catch the event of hpaned's changing slider position. According to official doc, paned only have a few signals, and none of them is about slider's position. So, is there a event about hpaned's slider? And how to catch it? ...

delphi records and c structs

Task: Application written in Delphi accepts a structure (record in terms of Delphi) of three fields. I can send the pointer of this structure using SendMessage (Win32api) function. So a question is: How to maintain certain structure representation in memory for delphi in terms of delphi. It has type PWPModPostData = ^ TWPModPostDat...

Deleting node from linked list in C

Okay this is my code for deleting a node from a linked list. vec_store holds seq and size. Variable seq holds the vectors and a pointer. For some reason, the else if(i<s->size-1) doesn't work which is the last condition. Any1 can solve the problem? By the way this is C code. void delete_vec(vec_store s, int i) { if (i<0 || s->si...

When should one be careful using a bitset in place of a bool array?

I'm working on a mobile phone application and I see a potential opportunity for performance improvement. Throughout the code I use bool arrays to keep track of which objects are active. For example I'd check to see if the ith MyObject is active by doing the following: if(activeMyObjects[i]){ // it's active so do something... } Since...

how to synchronize a varied number of threads?

Hi, Could someone please help me with synchronizing varied number of threads? The problem is when the number of threads can vary from one to 9 and when for instance two clients are connected to server, the communication should be synchronized in this form : client1, client2, client1, client2 ... until the communication is over. I tried ...

How to copy a char[] in c into my struct

I am trying to send my struct over a UDP socket. struct Packet { int seqnum; char data[BUFFERSIZE]; }; So on the sender I have bytes = sizeof(packet); char sending[bytes]; bzero(sending, bytes); memcpy((void *) sending, (void *) &packet, sizeof(bytes)); bytes = sendto(sockfd, sending, sizeof(sending), 0, (struct sockaddr *...

Apache C module creation, problem linking SQLite

Playing around with this a bit, but not getting too far... The logic of my SQLite code works if I compile it as a stand-alone executable. My mod_hello.c compiles and loads/works fine without the SQLite code Combining the two, the module compiles and is installed, but the apache process dies immediately every time it is loaded. Strippi...

Right shifting negative numbers in C

I have a C code in which I do the following int nPosVal = +0xFFFF; // + Added for ease of understanding int nNegVal = -0xFFFF; // - Added for valid reason Now when I try the following printf ("%d %d", nPosVal >> 1, nNegVal >> 1); I get 32767 -32768 Q-1: Is this expected? I am able to think something like 65535 >> 1 = (int)...

How do I compare two timestamps in C?

I'm writing a socket program that maintains FIFO queues for two input sockets. When deciding which queue to service, the program pulls the most recent time-stamp from each queue. I need a reliable method for comparing two timeval structs. I tried using timercmp(), but my version of gcc doesn't support it, and documentation states that ...

How to resolve the segmentation fault due to strtok()?

Hi, I am getting segmentation fault when the below line is executed: result = strtok(data,delimiter); I have given the backtrace : Program received signal SIGSEGV, Segmentation fault. 0x44359e85 in strtok () from /lib/libc.so.6 (gdb) backtrace #0 0x44359e85 in strtok () from /lib/libc.so.6 #1 0x08048c02 in main () at multiply.c:36...

Converting a non-GUI Makefile (make) project to KDevelop

I have a rather simple C project I compile with make that I would like to run and debug in KDevelop, but I can't get this to work. I have installed cmake and tried both to import an existing project and start a new (which insists on creating a main.ccp file), but no matter what I do all the menu options to run the program are greyed out....

Regarding macros

Hi all.. may i know what is the problem in using the below x-macro code #define FILL_BUFF_1 (int *)(0x01, 0x02) #define FILL_BUFF_2 (int *)(0x03, 0x04) #define X(a,b) #define LOOK_UP \ X(0x13, FILL_BUFF_1), \ X(0x14, FILL_BUFF_2) #undef X #define X(a,b) a int pid_table[2] = {LOOK_UP}; #undef X #define X(a,b) b int *pid_b...

performance of table access

Hi, we are having an application which is completely written in C. for table accessing inside the code like fetching some values from atable we use pro*C and for increasing the performance of the application we also preload some tables for fetching the data.we take some input fields and fetch the output fields from the table in general....

select() on socket (trouble)

Recently I have done this part of code: http://dumpz.org/14945/ It does work, but select() works bad. When it has got last reply from server, it begins repeating last reply string with some strange characters in the beginning of reply string. So look at this: :[email protected] PRIVMSG testuser1 :VERSION �C���C��[email protected] PR...

add seconds to a date

i need to add a seconds in a date. for eg:if i have a date as 2009127000000, i need to add the seconds to this date. also for eg 20091231235957 adding 50 seconds. is this possible in C? ...

How to read the content of an other app's text field on OS X?

For a project I must create a little buddy app that will read the content of one of the main app's text fields. Is there a way to get to the contents of a window/control (I'm interested in the text of the text field) on OS X? Something like GetDlgItemText() on Windows where I just pass the control's global handle and will get the contr...

How to escape the % sign in C's printf?

How do you escape the % sign when using printf in C? printf("hello\%"); /* not like this */ ...

Reading a file line by line in C

Hello, I am trying to write some code that will open a file, read its content line by line and store each of these lines into an array. First I open the file and count the number of lines, each of the lines is of a fixed length so I simply do this : char buf2[LINE_LENGTH]; int in2 = open("toSend2", O_RDONLY); int number_o...

Trouble with Calendar homework in C

I am writing a program that get month and year from the user, and then print out the calendar. But the calendar is only correct in January (every two years). How do I make the other months correct? What am I doing wrong? #include "stdafx.h" void printMonth (int* startDay, int* days); int _tmain(int argc, _TCHAR* argv[]) { int s...

Problem writing array of doubles to a file

i have a really big array of numbers with double precision...i tried to write it into a file using fprintf()...i need to write these numbers one in each line so i have done something like this. if((fp2 = fopen("temp", "w")) == NULL) { perror("File cannot be opened"); exit(1); } for(int k = 0; k < j; k++ ) { fprintf(fp2, "%0.3lf\n", dif...