c

The best ide for gtk+ programming

Hello, Recently i start to studying C/gtk+ programming. And want to ask one question: how do you think, what is the best ide for C/gtk+ development? Thank you. ...

efficient way of searching a character in a set of character C language

Hi, I have a set of characters, minimum hundreds of characters. How could i get the position of a particular character in that list efficiently. ...

Convert double to int on Arm RVCT compiler in C language

I need to get last four bytes out of a double variable .The platform is Arm and compiler is RVCT.Programming language used is C.What is the safest way. Thanks ...

c struct question

Hi, I'm trying to implement a simple priority queue from array of queues. I'm trying to define a struct queue, and than a struct priority queue that has an array of queues as its member variable. However, when I try to compile the code, I get the following error: pcb.h:30: error: array type has incomplete element type The code is bel...

C question: error: expected ')' before '*' token

Edit 2 Thanks for all the suggestions, I edited the code below from the suggestions given. However, it still doesnt seem to compile. But nevertheless, thanks a lot for the help hands. Edit I apologize for not putting the pcb struct into the code snippet. There is a struct called pcb defined in above the two structs I originally posted...

How is it legal to reference an undefined type inside a structure?

As part of answering another question, I came across a piece of code like this, which gcc compiles without complaint. typedef struct { struct xyz *z; } xyz; int main (void) { return 0; } This is the means I've always used to construct types that point to themselves (e.g., linked lists) but I've always thought you had to name t...

What is the cost of a #define?

To define constants, what is the more common and correct way? What is the cost, in terms of compilation, linking, etc., of defining constants with #define? It is another way less expensive? ...

Hide struct definition in static library.

Hi, I need to provide a C static library to the client and need to be able to make a struct definition unavailable. On top of that I need to be able to execute code before the main at library initialization using a global variable. Here's my code: private.h #ifndef PRIVATE_H #define PRIVATE_H typedef struct TEST test; #endif pri...

casting char[][] to char** causes segfault?

Ok my C is a bit rusty but I figured I'd make my next(small) project in C so I could polish back up on it and less than 20 lines in I already have a seg fault. This is my complete code: #define ROWS 4 #define COLS 4 char main_map[ROWS][COLS+1]={ "a.bb", "a.c.", "adc.", ".dc."}; void print_map(char** map){ int i; for(i=0;...

serial port in C

I have written a program in C to send a byte to serial port (com). I have used BIOSCOM to send data but I guess that it doesn't open the port. Please tell how I can open and close a com port in C. My code is here: #define COM1 1; bioscom (1 , 65 , COM1); Please help me... ...

How do I get a GtkTreePath or GtkTreeIter to the last row in a GtkTreeModel?

I want to get a GtkTreePath or GtkTreeIter to the last row in a GtkTreeModel, but GtkTreeModel does not have a function for that. I'll be happy with answers and examples in either C, or Python, or both ;). ...

Can I make valgrind ignore glibc libraries?

Is it possible to tell valgrind to ignore some set of libraries? Specifically glibc libraries.. Actual Problem: I have some code that runs fine in normal execution. No leaks etc. When I try to run it through valgrind, I get core dumps and program restarts/stops. Core usually points to glibc functions (usually fseek, mutex etc). I und...

mixed declarations and codes

When I compile function with "gcc -o dene -Wall -ansi -pedantic-errors dene.c" ,gcc emits no error.(can you look a line which starts with char ....,in if loop,) static void remove_negation(char *s,char *s1) { char **cmainp=malloc(sizeof(char*)*1); int len=0;int d=0; int i=0; ...

Avoding multiple thread spawns in pthreads

Hi StackOverflow, I have an application that is parallellized using pthreads. The application has a iterative routine call and a thread spawn within the rountine (pthread_create and pthread_join) to parallelize the computation intensive section in the routine. When I use an instrumenting tool like PIN to collect the statistics the tool ...

Construction an logical expression which will count bits in a byte.

When interviewing new candidates, we usually ask them to write a piece of C code to count the number of bits with value 1 in a given byte variable (e.g. the byte 3 has two 1-bits). I know all the common answers, such as right shifting eight times, or indexing constant table of 256 precomputed results. But, is there a smarter way with...

How to store/retrieve an NSMutableArray of objects?

How do I store/retrieve an NSMutableArray of objects? The easy / fast way please. Thanks! ...

dereferencing the null pointer

int* p = 0; int* q = &*p; Is this undefined behavior or not? I browsed some related questions, but this specific aspect didn't show up. ...

Socket read() hangs for a while when there is no data to read.

Hi' I'm writing a simple http port forwarder. I read data from port 80, and pass the data to my lighttpd server, on port 8080. As long as I write() data on the socket on port 8080 (forwarding the request) there's no problem, but when I read() data from that socket (forwarding the response), the last read() hangs a lot (about 1 or 2 seco...

Struct declaration error in C

ive got a struct problem it returns: cd.h:15: error: two or more data types in declaration specifiers its probably something simple ... struct cd { char titel[32]; char artiest[32]; int speelduur; }; typedef struct cd CD; struct cdlijst{ CD *item; struct cdlijst *next; } ...

How to increment a value using a C-Preprocessor in Objective-C?

Possible Duplicate: Can you make an incrementing compiler constant? Example: I try to do this: static NSInteger stepNum = 1; #define METHODNAME(i) -(void)step##i #define STEP METHODNAME(stepNum++) @implementation Test STEP { // do stuff... [self nextFrame:@selector(step2) afterDelay:1]; } STEP { // do stuff.....