c

Save response type "Content-Type : text/javascript" in text file

Hi, I am getting some response of HTTP request. Response header is "Content-Type : text/javascript" and some response body. I want to save this response body in text file as "a.txt". Can I do it ? I have "C" files in which I have to do it. Regards PJ ...

angle in iphone sdk?

hi, how to calculate angle between two points in iphone sdk...? ...

How to execute Python script from CreateProcess in C on Windows?

I have managed to get C code calling Python scripts happily on Unix using PIPES within the C code. I now need to do the same on Windows. Essentially I would like to write scripts in different scripting languages like Python / Lua etc on Windows and be able to execute them using STDIN / STDOUT etc. I have been looking at the "CreateProc...

How to find repeating sequence of characters in given array

my problem is to find the repeating sequence of characters in the given array. simply, to identify the pattern in which the characters are appearing. example: for the examples in the above image the output for the First array should be "JAMESON" Second array should be "RON" Third array should be "SHAMIL" Fourth ar...

Undefined reference while using g++ for compilation

Hi, I am getting following error p.c uses some of the function implemented in md4.c. p.c , when compiled with gcc works but it does not work with g++, gives undefined method error. Am I missing something obivious ? [prafulla@ps7374 sample] $g++ -c -o md4.o md4.c [prafulla@ps7374 sample] $gcc -c -o md4.o md4.c [prafulla@ps7374 sample] $...

When abort() is preferred over exit()?

I know the differences between the two. One notable thing is that abort() sends SIGABRT signal, so it may be relevant when your software relies on them. But for a typical application exit() seems to be more safe version of abort()...? Are there any other concerns to use abort() instead of exit()? ...

Memory Layout of application

Hi, The following question is a head-scratcher for me. Assuming that I have two platforms with an identical hardware, the same OS and the same compiler on it. If I compile exactly the same application, can I be sure that the memory layout on both machines will exactly be the same? In other words, both applications have exaclty the same ...

What does getchar() exactly do?

I am reading K&R and I am baffled in working of this program. #include<stdio.h> main(){ int c; c = getchar(); while(c != EOF){ putchar(c); c = getchar(); } } When we enter a string, it gives the same output. I have 2 doubts - How it outputs whole string? I would expect it to read one character and a...

error : storage class specified for parameter

I have a c code written.when i compile it on Linux then in the header file it says the following error : storage class specified for parameter i32 , i8 and so on typedef int i32; typedef char i8; I am new to linux....can anyone help plzz ...

Do C functions support an arbitrary number of arguments?

Hi. PHP has a func_get_args() for getting all function arguments, and JavaScript has the functions object. I've written a very simple max() in C int max(int a, int b) { if (a > b) { return a; } else { return b; } } I'm pretty sure in most languages you can supply any number of arguments to their max()...

Can we call a function inside a routine where the function return data type is void?

For example, I have: void(temperature, pressure,time) { int i; double results[10]; for (i = 0 ; i <= 9 ; i++) { fx(temperature, pressure, time); results[i]=fx[i]; } } (P/S: above is the simplified version of my real problem) fx by itself is of course another ste of codes with equations for calcul...

Is there an easy way to convert a number to hexidecimal ASCII chars in C?

I am working a C firmware program for an embedded device. I want to send an array of hex char values over the serial port. Is there a simple way to convert a value to ASCII hex? For example if the array contains 0xFF, I want to send out the ASCII string "FF", or for a hex value of 0x3B I want to send out "3B". How is this typically do...

Is _write in io.h a blocking call?

I've inherited some code which, to initialise some hardware, writes a few bytes and then waits for a return. To do this it calls the _write function from io.h. From my testing, it looks like it's locking up at that point. So my questions are as follows: Is that function a blocking function? Is there a way of setting a timeout? Is there...

Have I missed the point of pointers?

OK, sorry about the bad pun :P I've coded the old trick of HAL => IBM in C. I've just read the first few pages in K&R reguarding them, and I thought it would be a good first play with them. char evil[] = "HAL"; char *ptr = evil; for (int i = 0; i < strlen(evil); ++i, ++ptr) { (*ptr)++; } printf("%s\n",...

Is it safe to pass "too many" arguments to a external function?

This situation can only occur without name mangling (I believe), so the below code is C. Say there is a function A defined in A.c as void A(int x, int y){ //Do stuff } Now there is also a separate file B.c: extern "C"{ void A(int x, int y, int z); } void B(){ A(1, 2, 3); } A is initially declared to have only 2 argumen...

Right syntax in C to define an array of 3D pointers

Hi, in a C program I need to define float (*d_i)[3]; but later I realized that I need to define NMAX variables of this type. I tried with float (*d_i)[3][NMAX]; but it does not work. what would be the right syntax? Thanks ...

C & Lua: luaL_dostring return value

Hey, in my C file I call luaL_dostring like this: luaL_dostring(L, "return 'somestring'"); How do I read this return value in C after this line? Thanks. Edit: Thanks for the help. I'd like to add that to remove the element after retrieving it, you use: lua_pop(L, 1); ...

Easier way to create alphanumeric + '_' string from existing string?

Is there a better/easier way to create a \w+ string from an existing string? char *FixName(char *name) { char *ptr, tmp; char *new = malloc(strlen(name)+1); sprintf(new, "str_"); for (ptr = name + 4; *ptr; ptr++) { if ((*ptr >= '0' && *ptr <= '9') || (*ptr >= 'A' && *ptr <= 'Z') || ...

Why does Win32 API function CredEnumerate() return ERROR_NOT_FOUND if I'm impersonated?

I've written some sample code which when I call from the windows command prompt under the context of a normal user account, dump's all the user's saved credentials using CredEnumerate(). However, I really want to be able to do this from SYSTEM user context so I've tested my program from a SYSTEM cmd prompt. When I running my program a...

Need to Write C code from C++ Code ?

I need to write my 4-5 .cpp and .h file to c code. In C++ code we have defined class,constructor,destructor,function in the class. How to convert them in C code ? Can somebody give me example of it so that i can implement it or provide link so that i can better explore it to my C code ? How to implement all the functionality i mean cons...