c

How can I measure the level of ambient light from an image?

I am looking at making an app that uses a camera to measure the amount of light present when an image is taken. Some conditional behavior would take place based on how much light was present - ie display a message saying "Looks like bedtime" if it looks like it is dark. I understand that this will be a pretty poor measure of the actual ...

VS2010 C code - String pooling

Hi, Below code crash in VS 2010 when you compile with following flag and if you add /GF- or remove the opimization flag they don't crash. The crash occur at assembly code which translate 'if( path[i] == '/' )'. I like to understand the optimization that compiler does here and lead to crash. Looking forward for some pointers. -Karthik ...

Manually zeroing variables VS copying struct

I have a long C (not C++) struct. It is used to control entities in a game, with position, some behavior data, nothing flashy, except for two strings. The struct is global. Right now, whenever an object is initialized, I put all the values to defaults, one by one myobjects[index].angle = 0; myobjects[index].speed = 0; like that. It d...

char* as an argument to a function in C

When passing a char* as an argument to a function, should the called function do a free on that string? Otherwise the data would be "lost" right and the program would leak data. Or are char* handled in a special way by the compiler to avoid everyone from having to do free all the time and automatically deletes it one it goes out of scope...

Algorithm and data structure implementations for C programmers

Possible Duplicate: Are there any open source C libraries with common data structures? What is the best source of algorithm and data structure implementations for C programmers? Links to an open source library or a book will do. (Please don't point to Sedgewick, as I already have his book). ...

Createfile function

I am creating the file using Createfile function. The C program is working fine but I am unable to see the created file in the respective folder. Also "view hidden files" option is checked. ...

ANSI C hash table implementation with data in one memory block

Hello, I am looking for an open source C implementation of a hash table that keeps all the data in one memory block, so it can be easily send over a network let say. I can only find ones that allocate small pieces of memory for every key-value pair added to it. Thank you very much in advance for all the inputs. EDIT: It doesn't necess...

TCP connection - delayed close() and RST

Hi, I have both TCP client and TCP server run on RHEL 5.3 on different machines. I'm killing server and FIN is sent to the client. ACK is sent back by client's OS back immediately. Client discovers the close (by read() returning zero) and perfroms close only after 90 sec. At this stage I verified netstat on both sides and it's as expe...

Are there any C APIs to extract the base file name from its full path in Linux?

I guess the title says it all. Given the full path, the API should give me the base file name. E.g., "/foo/bar.txt" --> "bar.txt". ...

Getting gateway to use for a given ip in ANSI C

I have looked around like crazy but don't get a real answer. I got one example, but that depended on the individuals own library so not much good. At first I wanted to get the default gateway of an interface, but since different IP's could be routed differently I quickly understood that what I want it get the gateway to use for a given ...

Can makefile variables be assigned with values read from source files?

Suppose there is a C program, which stores its version in a global char* in main.c. Can the buildsystem (gnu make) somehow extract the value of this variable on build time, so that the executable built could have the exact version name as it appears in the program? What I'd like to achieve is that given the source: char g_version[] = "...

Send input to a program and get control back

Hello, I have been stuck on this for some time. Let's say I have a C program like the following. I want to be able to send this program some string and get the control after that. If I do: --> cat myfile | myprogram or --> echo "0123" | myprogram or --> myprogram < myfile I get the ouput (myfile contains "0123") 30 31 32 33 Usi...

validating X.509 certificate on linux

I have just started working with X.509 certificates. Can any one tell me how to go about validating a certificate on linux? The use case is that my app had downloaded a certificate in a previous session and I have to check if it is still valid (i.e., not expired or revoked since it was stored) before starting a new session. I understand ...

High performance RSA implementation for C# or C

Hi! I have an webservice that performs many RSA-signature operations. I use the CryptograhyProvider from .net. This uses the unmanaged CyptoAPI from Windows. I often have this error: System.Security.Cryptography.CryptographicException: Der RPC-Server ist für diesen Vorgang zu stark ausgelastet. [=The rpc server is too busy to complet...

how to store 8 bits in char using C

what i mean is that if i want to store for example 11110011 i want to store it in exactly 1 byte in memory not in array of chars. example: if i write 10001111 as an input while scanf is used it only get the first 1 and store it in the variable while what i want is to get the whole value into the variable of type char just to consume onl...

Output difference in gcc and turbo C

Why is there a difference in the output produced when the code is compiled using the two compilers gcc and turbo c. #include <stdio.h> int main() { char *p = "I am a string"; char *q = "I am a string"; if(p==q) { printf("Optimized"); } else{ printf("Change your compiler"); } return 0...

eclipse ide needed to be integratewd with misra rules

how can i integrate misra rules with eclipse ...

Highlight C/C++ Programming Mode in WinEdit 5.5

Hi all, I would like to use Winedit 5.5 to write my C-programs. Anyone knows how I can active C/C++ highlighening in this editor? I looked around for quite a while on google, but I did not come across an easy solutions. Thanks for any hints, Markus ...

typedef and non-simple type specifiers.

Why is this code invalid? typedef int INT; unsigned INT a=6; whereas the following code is valid typedef int INT; static INT a=1; ? As per my understanding unsigned int is not a "simple type specifier" and so the code is ill-formed. I am not sure though. Can anyone point to the relevant section of the Standard which makes the fi...

Consequences of this buffer overflow?

So here I believe I have a small buffer overflow problem I found when reviewing someone else's code. It immediately struck me as incorrect, and potentially dangerous, but admittedly I couldn't explain the ACTUAL consequences of this "mistake", if any. I had written up a test app to demonstrate the error, but found (to my dismay) that it...