c

How to parse HTTP responses in C?

Hi, I'm writing a little project which interacts with a set of servers using HTTP 1.1 GET and POST. The server gives me the response after some header lines, so I though on using strtok() function using \n as the delimiter but there is a crash whenever I try to do so. Is there any simple way to parse a HTTP response in C? I would like n...

A few questions about my modular code using void* as dynamic data type in C

Hi, A few days ago I posted this question and everyone suggested me to use void*, which I did. I think some of them also pointed a few things that I would need to take care of but I'm not sure what exactly were they. However, I'm having a few problems with this... I'm not going to post all my code where cause it's quite large, instead,...

How to stretch a bitmap in C and SDL?

I am making a game for my CS class and the sprites I have found online are too small. How do you 'stretch' a bitmap... make them bigger using SDL? (I need to increase there size 50%, there all the same size.) A snippet of example code would be appreciated. ...

srand function in C

I am trying to code a random number generation function in embedded C where I can't include the math.h file. Thats why I'm not able to use the seed srand function. Is there any other way to seed it other than time? ...

Conversion from YUV444 to RGB888

I am new in this field and i desperately need some guidance from u all. I have to support yuv444 to rgb 888 in display driver module. There is one test which i have done for yv12 rgb565 in wince 6.0 r3 which is mentioned below. //------------------------------------------------------------------------------ // // Function: PP_CS...

Operator associativity in C specifically prefix and postfix increment and decrement

In C operation associativity is as such for increment, decrement and assignment. 2. postfix ++ and -- 3. prefix ++ and -- 16. Direct assignment = The full list is found here Wikipedia Operators in C My question is when we have int a, b; b = 1; a = b++; printf("%d", a); // a is equal to 1 b = 1; a = ++b; printf("%d", a)...

Create a file in linux using c

I am trying to create a write only file in c on Linux (ubuntu). This is my code: int fd2 = open ("/tmp/test.svg", O_RDWR|O_CREAT); if (fd2 != -1) { //.... } But why the file I created are in 'xr' mode? How can I create it so that I can open it myself at command prompt? ------xr-- 1 michael michael 55788 2010-03-06 21:57 test...

C: Unpacking a byte

I asked the question here and now i would like to reverse this procedure I have an unsigned short that represents a bit pattern, I would like an array of bool[16] that has true or false set for the corresponding bit in the unsigned short. so far i have where binary 2 is an unsigned short, that has the bit pattern i wish to unpack. un...

c - output to file

If I had an array of integers I wanted to output to a text file.. void output() { for (i=0; i<10; i++) printf("%d ", values[i]); } How can I save the output() to text file using the method below? void writeToFile() { file = fopen("file.txt","a+"); // apend file or create a file if it does not exist fprintf(f...

input-output in C

double d; scanf("%f", &d); printf("%f", d); result: input: 10.3 output: 0.00000 Why? i think output should be 10.3 visual studio 2008. ...

Static code Anaylysis tool for C and C++

Possible Duplicate: What open source C++ static analysis tools are available? I am Looking for a static code analysis tool for C and C++ on a Unix platform. Can you please recommend one for me, that you have used your self or know about. ...

Using C Code in C++ Project

Hi .. I want to use this C code in my C++ project : mysql.c : /* Simple C program that connects to MySQL Database server*/ #include <mysql.h> #include <stdio.h> #include <string.h> main() { MYSQL *conn; MYSQL_RES *res; MYSQL_ROW row; char *server = "localhost"; char *user = "root"; char *password = "rebourne"; /* se...

c - random number generator

How do I generate a random number between 0 and 1? ...

Remove new line character in C

I am trying to use getc(character) to take an element from a file and do stuff with it, but it appears that it must have a '\n' before the end of a line is met. How can I remove this so that when I copy the characters I don't have a new line charachter appearing anywhere - thus allowing me to deal with printing new lines when I choose? ...

Different Linux message queues have the same id?

I open a mesage queue in a .c file, and upon success it says the message queue id is 3. While that program is still running, in another terminal I start another program (of another .c file), that creates a new message queue with a different mqd_t. But its id also appears as 3. Is this a problem? server file goes like this: void server(...

How to organise a C project in Eclipse /w multiple binaries ?

I'm in the process of converting a project to Eclipse CDT, it consists of 2 (static) libraries and produces about 12 binaries, a few of the binaries have 2-3 different build configurations, and is built by scons How should I structure this in an Eclipse workspace ? 1 project for everything ? 1 project for each of the binaries/libs ? Som...

I have a text-box and i want to enter a string in language A...

OK I will try to ask it again. I have a text-box and I want to enter a string in language A and send it to "google translate". After Google has translated it I want to take the new string(in language B) (after translation) and store it in some variable. I hope this time it is more clear. How I do it?? ...

Bit packing of array of integers

I have an array of integers, lets assume they are of type int64_t. Now, I know that only every first n bits of every integer are meaningful (that is, I know that they are limited by some bounds). What is the most efficient way to convert the array in the way that all unnecessary space is removed (i.e. I have the first integer at a[0], ...

fread/fwrite string in C

I have a binary file which contains records. The structure of the file is as such: Structure (see below) Name String Address String The structure in question: typedef struct{ char * name; char * address; short addressLength, nameLength; int phoneNumber; }employeeRecord; employeeRecord record; I get the name as such:...

Difference between "pointer to int" and "pointer to array of ints"

int main() { int (*x)[5]; //pointer to an array of integers int y[6] = {1,2,3,4,5,6}; //array of integers int *z; //pointer to integer z = y; for(int i=0;i<6;i++) printf("%d ",z[i]); x = y; for(int i=0;i<6;i++) printf("%d ",(*x)[i]); return 0; } ...