c

Removing diacritic symbols from UTF8 string in C

Hi all, I am writing a C program to search a large number of UTF-8 strings in a database. Some of these strings contain English characters with didactics, such as accents, etc. The search string is entered by the user, so it will most likely not contain such characters. Is there a way (function, library, etc) which can remove these ...

scanf fails why?

Hi, when I wrote this ,compile and run: int x; scanf ("%d", &x); while (x!=4) { scanf ("%d", &x); } and when inserting char or double number less than 4 it enter an infinite loop. when inserting double greater than 4 it terminates. Any explanation? ...

writing a Telnet server and Telnet client in C

Hi, I have selected an project for writing a Telnet server and Telnet client code in C. i am learning C programming. Has anyone attempted this.Please tell me how to proceed and materials to be refer. sorry for asking source code.I am not getting how to start.So please refer me the material,so i can try the platform i am using is ubu...

How to use libpng with OpenGL for a 2D game?

I am beginning with OpenGL, and I want to make a very simple game with airplanes. Now I have a PNG of an airplane seen from above, and I want to draw this on the screen. Currently I only know how to draw triangles that rotate: float angle = 0.0f; void renderScene(void) { glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); glRotatef(angl...

C data structure library

I want to use a stack in C, anybody recommend a library? For example for a hash table I used UThash. Thanks! ...

PostgreSQL's libpq: Encoding for binary transport of ARRAY[]-data ?

Hello, after hours of documentations/boards/mailinglists and no progress I may ask you: How do I 'encode' my data to use it for binary transport using libpq's PQexecParams(.) ? Simple variables are just in big endian order: PGconn *conn; PGresult *res; char *paramValues[1]; int paramLengths[1]; int paramFormats[1]; conn = PQconnectdb...

implementing callback between Python and C

I have wrapped some C code using SWIG to use it as a python library. Within this framework, some python code I have written calls a C function, which returns a string. However, for creating the string, the C function requires a ranking, the generation of which I have implemented in Python. How would I go about implementing this using ca...

Accessing/modifying an array of strings in a structure

Suppose I have the following code: typedef struct { char **p; } STRUCT; int main() { STRUCT s; *(s.p) = "hello"; printf("%s\n", *(s.p)); return 0; } which obviously doesn't work, but it should show what I want to do. How would I go about initialising, accessing, printing, etc the array of strings in the structure...

Tutorial on C pointers

Hi, right now I'm trying to teach someone about C programming. Specifically right now we're on pointers in C. However I feel this is a difficult concept to explain, as the person I'm teaching doesn't have much programming experience. I was wondering if anybody knew of a good tutorial on C pointers for a true beginner programmer? I've tr...

Sleeping in a Thread (C / POSIX Threads)

I am developing a multithreaded application that makes use of POSIX Threads. I am using threads for doing a periodical job and for that purpose I am using usleep(3) to suspend thread execution. My question is how can I cancel usleep() timer from the main thread, I tried pthread_kill(thread, SIGALRM) but it has a global effect which resul...

Dynamic Contiguous 3D arrays in C

I'm trying to implement dynamically allocated contiguous 3D arrays in a C code. The arrays must be contiguous because I'm relying on netCDF output of the arrays. Now I adapted a solution posted here Stack OverFlow Solution. This works fine for dynamically allocating the arrays and indexing them...however, when netCDF outputs them ther...

How to access ms sql server 2008 in c?

I know little about sql server access, and all googled out for sql server accessing are using C# or php like language. Is there a good step by step about how to set up sdk and write an start program in c to access sql server database? ...

Why aren't my variables holding state after WaitForSingleObject?

I am implementing a Go Back N protocol for a networking class. I am using WaitForSingleObject to know when the socket on my receiver thread has data inside it: int result = WaitForSingleObject(dataReady, INFINITE); For Go Back N, I have to send multiple packets to the receiver at once, and manipulate the data, and then send an ACK pac...

How can I strength reduce division by 2^n + 1?

I need to perform some integer divisions in the hot path of my code. I've already determined via profiling and cycle counting that the integer divisions are costing me. I'm hoping there's something I can do to strength reduce the divisions into something cheaper. In this path, I am dividing by 2^n+1, where n is variable. Essentially I w...

implementing a TRIE data structure

Hii , i Was implementing a trie in C ... but i am getting an error in the insert_trie function . I could not figure out why the root node is not getting updated . Please help me with this. #include<stdio.h> #include<stdlib.h> #include<malloc.h> typedef struct { char value; int level; struct node *next; struct node *list; }n...

Expression evaluation in C/C++ doesnt follow BODMAS rule?

When a expression is evaluated in C/C++, does it follow BODMAS [Bracket open Division Multiply Addition Substraction] rule? If not then how they are evaluated? EDIT: More clearly, If the following expression is evaluated according to BODMAS rule, (5 + 3)/8*9 First what is in brackets is processed. 8/8*9. Then Division is done. 1*9...

What's the fastest C++ class or C library to convert latitude and longitude from decimal degrees to string and back

I'm looking for the best C or C++ code to encode and decode decimal latitude and longitude values from/to double/char. I'd prefer the code convert from double to char[] and vice-versa rather than c++ strings. If you have a code snippet that would be great too. To clarify: I need to convert from a string Degrees/Minutes/Seconds to doub...

run an infinite loop for a while in c

Hello everybody. I want to run an infinite loop for a while. Basically, i want to have something like this //do something while(1){ //do some work } //do some other thing but i want the running time of the loop to be fixed, example, the loop could be running for 5 seconds. Do somebody have an idea? ...

How to parse through a C/C++/C# project and write all packages/classes/methods into a database?

Hi For my new application I would like to parse another C, C++ or C# project, so that i can later display the graphical representation of all the classes in this project. So I thought that its a good approach to use a database with the following tables to store the necessary information: TablePackages: id | name | parentID TableClass...

Initializing array inside struct - C?

Seem to have a memory allocation problem and think it's because in my struct, there is a pointer to an array of another struct. However, I'm not initializing this array and not sure how: typedef struct listitem { struct listitem *next; Entry *entry; } ListItem; typedef struct list { ListItem *table[100]; } List; List *init...