c

Disadvantages of using void* pointers in C

there are many drawbacks using void* in C(memory related, type related,efficiency wise ...). inspite of them we use them a lot for the flexibility they provide. list the disadvantages/drawbacks using void* (and preferd solution in C - if possible). EDIT: please go thru the follwoing link: http://attractivechaos.wordpress.com/2008/10/02...

Looking for OSS for OSI Layer 2 Traffic Generator

I am looking for layer 2 traffic generator [open source]. Some OSS using winpcap or libpcap. Thanks a lot. ...

Avoiding a fork()/SIGCHLD race condition

Please consider the following fork()/SIGCHLD pseudo-code. // main program excerpt for (;;) { if ( is_time_to_make_babies ) { pid = fork(); if (pid == -1) { /* fail */ } else if (pid == 0) { /* child stuff */ print "child started" exit } else { ...

How do C/C++ compilers handle type casting?

I am curious to know how Type Casting happens without loss of data inside the compiler. For example: int i = 10; UINT k = (UINT) k; float fl = 10.123; UINT ufl = (UINT) fl; // data loss here? char *p = "Stackoverflow Rocks"; unsigned char *up = (unsigned char *) p; How does the compiler handle this type of typecasting. A lo...

Can you statically compile a cygwin application?

Does cygwin allow a statically compiled binary? This would prevent the need for cygwin1.dll being on the PATH of target machines. ...

Passing a dynamic array in to functions in C

I'm trying to create a function which takes an array as an argument, adds values to it (increasing its size if necessary) and returns the count of items. So far I have: int main(int argc, char** argv) { int mSize = 10; ent a[mSize]; int n; n = addValues(a,mSize); for(i=0;i<n;i++) { //Print values from a }...

Viewing language (C/C++) reference/documentation in CodeBlocks

Hi there! My first question on StackOverflow... Does anybody know a way of viewing the reference/documentation manual of a language through CodeBlocks? Specifically for C/C++. Example: Say I want to look up the reference for strncpy(). In a very old Borland system (which we use at school) I would write the word and middle-click on it,...

bmp loader library

I'm looking for a C library to load .BMP image-files. I've found a lot of code on the net, but everything I've seen so far is useless for me. Either the code seems to be in a good shape but it only supports just or two of the possible sub-formats, or the code supports all major sub-formats but does not error-checking and handling at al...

is there a replacement for unistd.h for Windows (Visual C)?

I'm porting a relatively simple console program written for unix to the Windows platform. (VC++ 2005). All the source files include "unistd.h", which doesn't exist. Removing it, i get complaints about misssing prototypes for 'srandom', 'random', and 'getopt'. I know I can replace the random funcs, and I'm pretty sure I can find/hack-u...

How do I base64 encode (decode) in C?

I have binary data in an unsigned char variable. I need to convert them to PEM base64 in c. I looked in openssl library but i could not find any function. Does any body have any idea? ...

C Programming Exercise from the K&R Book.

Any idea why the following code doesn't print the amount of characters in the input? I've taken this straight from the K&R book. Learning C at the moment and this is really confusing, looks to me like I'm never reaching EOF. If that's the case then why would this be used as an example? #include <stdio.h> main() { double nc; fo...

How can I make my server have open connections to multiple clients at the same time?

I want to write my own little chat server in C on a MacOS machine. Now I want to connect to all clients, that are online and let the connection open, to be able to receive and send messages. The problem is that I only know, how to have one socket connection at a time open. So only one client can connect so far and chatting like that is k...

Memcached client for Windows in C or C++?

I need a portable C/C++ solution, so I'm looking for a C/C++ client library for Memcached that work on both Windows and Unix. Any suggestions? ...

C data structure to mimic C#'s List<List<int>>?

I am looking to refactor a c# method into a c function in an attempt to gain some speed, and then call the c dll in c# to allow my program to use the functionality. Currently the c# method takes a list of integers and returns a list of lists of integers. The method calculated the power set of the integers so an input of 3 ints would pr...

Where does gcc look for C and C++ header files?

On a Unix system, where does gcc look for header files? I spent a little time this morning looking for some system header files, so I thought this would be good information to have here. ...

How is Tail Call Optimization implemented in DrScheme?

I've heard that trampolining is an ineffective way of implementing TCO. How does DrScheme (PLAI Scheme, technically) do it? Does it do it the 'right' way (that is, produce assembly code which directly branches to the tail call, instead of going through the stack and trampolining)? ...

How to find the size of decoded base64 data in C

I have an function which decodes the encoded base64 data in binary data but I dont know how to find the length of decoded data. I use the BIO functions in openssl. unsigned char *unbase64(unsigned char *input, int length) { BIO *b64, *bmem; unsigned char *buffer = (unsigned char *)malloc(length); memset(buffer, 0, length); ...

Will .NET take over C/C++ any time?

This is a subjective question. I worked in Visual Basic 6.0 before coming into the .NET space. One thing I see that there are a lot of things, for which there is a need to deal with the Win32 API. As a Visual Basic 6.0 developer, there were a lot of limitations. .NET fixes some of the old problems however the need to rely on Win32 has...

What is the difference between a static global and static volatile variable?

I have used a static global variable and a static voltalile variable in file scope, both are updated by an ISR and a main loop and main loop checks the value of the variable. here during optimization neither global vriable nor the volatile variable are optimized. So instead of using a volatile variable a global variable solves the probl...

C language problem

Hi guys I want to create a program that requests from the user 10 grades and then filters them to pass and fail, then prints the number of passes and fails. I did the program but the output is wrong. int pass,fail,grade,studentcounter; pass=0; fail=0; grade=0; studentcounter=10; while (studentcounter!=0) { printf("enter the next ...