c

Modular data structure in C with dynamic data type

Hi, For my upcoming university C project, I'm requested to have modular code as C allows it. Basically, I'll have .c file and a corresponding .h file for some data structure, like a linked list, binary tree, hash table, whatever... Using a linked list as an example, I have this: typedef struct sLinkedList { int value; struct s...

Two hash tables, hash table with double key or different solution?

Hi, Once again, talking about my upcoming university project... I had a class today, where we could ask stuff about the project but I still haven't decided on the best way to do this. Basically, I have a bunch of users (some struct with a couple of members) which must be quickly searched by name and by SSN. Since I will also need to us...

How can I see an the output of my C programs using Dev-C++?

Hi, I'm looking to follow along with The C Programming Language (Second Addition) on a machine running Vista. So far, I've found Dev-C++ the easiest IDE to do this in. However, I still have one problem. Whenever I run my compiled code, for example: a simple hello world program, it runs, but the console window just flickers on the screen...

C code compilation failure

i have this makefile below and in it my includes are gtk/gtk.h and webkit/webkit.h but when i try to build the project using the make command i have the errors error: gtk/gtk.h: No such file or directory error: webkit/webkit.h: No such file or directory in case the gtk+-2.0.pc and webkit...pc are in the usr/lib/pkgconfig Make Fil...

Input in C. Scanf before gets. Problem.

Hi! I'm pretty new to C, and I have a problem with inputing data to the program. My code: #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { int a; char b[20]; printf("Input your ID: "); scanf("%d", &a); printf("Input your name: "); gets(b); printf("---------"); printf("Name: ...

Problem receiving UDP message from server.

I have to connect to a remote server via UDP and send a predetermined message to it in order to get a message back. I had first tried this in TCP and it worked but in UDP after I send the message and listen for the reply in recvfrom() I get nothing. Can anyone tell me what might be the problem here. if ((bytes_sent = sendto(sockfd, UDP_...

Assigning a value to variable

If I wanted to convert binary into decimal, is there way I could do this: Assuming: newState[i-2] = 0, newState[i-1] = 0, newState[i] = 1 binary = newState[i-2], newState[i-1], newState[i]; // but if I did this, bin = 0, not 001. I want to do this so I can pass binary into another method to convert into decimal. ...

Scintilla and thread safety

I'm using the Scintilla edit control on Windows (Win32, C/C++) . The control is created in WndProc. I have a second thread, created with Boost.Thread, that act as a spell checker and marks with red squiggle incorrectly spelled words. Therefore, I have two threads altering the content of the Scintilla control. At first, the program was ...

What would the evaluation order of x = x++ + ++x; be?

Possible Duplicate: Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc) In Java the evaluation order is specified to be left-to-right. Is this the case for C and C++ as well, or is it implementation dependent? I do remember that the evaluation order is unspecified for function arguments, but what ab...

Write a C program to measure time spent in context switch in Linux OS.

Can we write a c program to find out time spent in context switch in Linux? Could you please share code if you have one? Thanks ...

GLib atoms and memory chunks

The following code snippet is from The Official GNOME 2 Developer's Guide: GMemChunk my_chunk; my_chunk = g_mem_chunk_new("My Chunk", 42, 42*16, G_ALLOC_AND_FREE); gchar *data[50000]; gint i; /* allocate 40,000 atoms */ for(i = 0; i < 40000; i++) { data...

Automation Error - Not enough storage is available to process this command

VB6 CreateObject() is advising this error msg: "Automation Error" - "Not enough storage is available to process this command" The object being created is a DLL written in C. I'm running the application that's trying to create the object on my machine, and the object itself is being created on my machine also. I'm running Windows Vi...

Using pthreads in VS .NET 2003

Hi all, I'm having some problems with my program in VS .NET 2003. I initially wrote a module that uses the pthread library to create a number of threads to process something. This runs correctly in VS .NET 2003. Then this module was used by someone else and integrated into another larger program. I'm not sure about the details, but th...

Using sockets to read from client side

Hi, I basically have a server set up and I'm accepting new clients(UNIX) and i'm using select() command to wait for activity on file descriptor but I'm not sure how to write from the clients side and then read it on the servers side FD_ZERO(&readfds); FD_SET(server_sockfd, &readfds); FD_SET(STDIN_FILENO, &readfds); while (1) { test...

Why I cannot use my GMP library in Linux

Hi, I was writing some codes in linux using c. When tried to compiled, I got this response: /tmp/ccW8mQDx.o: In function `main': server.c:(.text+0x3e): undefined reference to `__gmpz_set_str' server.c:(.text+0x5a): undefined reference to `__gmpz_set_str' In fact, all the functions of gmp that I used couldn't be found. Seems there ar...

Can normal maps be generated from a texture?

Hi, If I have a texture, is it then possible to generate a normal-map for this texture, so it can be used for bump-mapping? Or how is normal maps usually made? Sandra ...

C function declaration

can we declare a function in a header file in following way? extern int ap( char[][] ); can we use char[][] in function? ...

How to Lock Queue Variable Address instead of using Critical Section ?

Hi, I have 2 threads and global Queue, one thread (t1) push the data and another one(t2) pops the data, i wanted to sync this operation without using function where we can use that queue with critical section using windows API. The Queue is global, and i wanted to know how to sync, is it done by locking address of Queue?. Answers wil...

How does operator precedence grouping work in C for *, /, and %?

Referring to the O'Reilly pocket reference for C, I'm a little confused by the description for grouping of the *, /, and % operators. The book says that grouping occurs left to right -- now I think I'm getting grouping confused with evaluation order. Given the following equation, and the rules established from the book, I would have thou...

With anonymous function in C# 4.0 why can't I define a delegate inline

What are the pro cons with having delegates having a reserved definition type. For example in c if I want to define a function that takes a pointer to a function I can simply define void F(bool (*pFn)(int)); In c# I have to take the extra step of first defining the delegate type similar if I had to create a typedef in c before I cou...