c

Issues with I/O in Multi-language compiling

Greeting Everyone I'm trying to compile and run a multi-language code in C, C++ and fortran using gcc, g++ & f77 respectively in UNIX. My program consists of two parts, one in C, the other in C++. They interface via a main() writen in C+, while the fortran code can be ignored for this case. I have been having numerous issues with this,...

Tool to explain C code

I remember from some time ago reading about a commandline tool that explains C code, does anyone know what it might be named? ...

The Benefits of Using Function Pointers

I have been programming for a few years now and have used function pointers in certain cases. What I would like to know is when is it appropriate or not to use them for performance reasons and I mean in the context of games, not business software. Function pointers are fast, John Carmack used them to the extent of abuse in the Quake and...

Cast to LPCWSTR???

I'm trying to create a (very) simple Win32 GUI program, but for some reason the compiler (I'm using VC++ 2008 Express) wants me to manually typecast every string or char* to LPCWSTR: I get this compiler error every time I do this, for example I get this error for the "Hello" and "Note": error C2664: 'MessageBoxW' : cannot convert param...

MySQL Batch Updates in C

Hi, Does MySQL's C API support batch updates? I'm writing an application where certain transactions are processed in large batches. It will grossly inefficient if in the logging process I wind up performing a single call DB for each insert. Does C have anything similar to Java's APIs for batch SQL updates? Thanks, N. ...

What's the most efficient way to make bitwise operations in a C array

I have a C array like: char byte_array[10]; And another one that acts as a mask: char byte_mask[10]; I would like to do get another array that is the result from the first one plus the second one using a bitwise operation, on each byte. What's the most efficient way to do this? thanks for your answers. ...

Are there any open source C libraries with common data structures?

I'm looking for a C library with common reusable data structures like linked lists, hash tables etc. Something like the source distributed with Mastering Algorithms with C (Paperback) by Kyle Loudon. ...

creating shared library using other library in linux

I have a shared library say "libeval.so". I am using this in my project to create on more shared library called say "lidpi.so". The library called "libdpi.so" is used by a tool. Now, this tool cannot see any other library other than "libdpi.so". I am using few function calls that are present in "libeval.so", and these are not present in ...

How could I implement logical implication with bitwise or other efficient code in C?

I want to implement a logical operation that works as efficient as possible. I need this truth table: p q p → q T T T T F F F T T F F T This, according to wikipedia is called "logical implication" I've been long trying to figure out how to make this with bitwise operations in C without using cond...

Problem Extending Python(Linking Error )?

I have installed Python 3k(C:\Python30) and Visual Studio Professional Edition 2008. I'm studying this. Here is a problem: C:\hello>dir Volume in drive C has no label. Volume Serial Number is 309E-14FB Directory of C:\hello 03/21/2009 01:15 AM <DIR> . 03/21/2009 01:15 AM <DIR> .. 03/21/2009 01:14 AM ...

How can I make splint ignore where I declare my variables?

Hi Do you know how can I make splint ignore where I declare my variables? I know that the old school c tells you to declare variables right at the beginning in every function, but since I am a bad person I like to declare things close to where I use them. A good example is to put int i; right before the for(i=0;...). Let's take a v...

ANSI C Bluetooth API and Tutorial Linux

Is there a bluetooth API and tutorial for ANSI C in Linux? ...

problem with socket programming in c\c++

#include "stdafx.h" #include <windows.h> #include <winsock.h> #include <stdio.h> int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR IpCmdLine,int nCmdShow) { WSADATA ws; char buf[100]; WSAStartup(0x0101,&ws); sprintf(buf,"%d.%d",HIBYTE(ws.wVersion),LOBYTE(ws.wVersion)); MessageBox(0,buf,"info",0...

Mixed indexing behaviour for typedef array?

I have a typedef: typedef unsigned char MyType[2]; I pass it to a function and the result is FAIL! void f(MyType * m) { *m[0] = 0x55; *m[1] = 0x66; } void main(void) { Mytype a; a[0] = 0x45; a[1] = 0x89; f(&a); } The manipulation of variable a in main() works on 1 byte indexing, so a is equal to {0x45, 0x89}. However in function...

Why was the ampersand chosen as the symbol for references in C++?

Does anyone have an idea why the ampersand was chosen as the way to denote references in C++? AFAIK (though I don't have the book near me), Stroustroup didn't explain that choice, which I find a little odd because the same symbol was already used for address-of in C. ...

Strange stack behavior in C

I'm worried that I am misunderstanding something about stack behavior in C. Suppose that I have the following code: int main (int argc, const char * argv[]) { int a = 20, b = 25; { int temp1; printf("&temp1 is %ld\n" , &temp1); } { int temp2; printf("&temp2 is %ld\n" , &temp2); } return 0; ...

How to search a specific node in a graph structure in C?

Not that I have time to discuss this properly to reach a conclusion and adapt my code because the phase one (of three) of a school project is in 24hrs, but at least I need to know if I did the correct decision. I'm using linked lists and here's my structures: typedef struct sCity { int cityID; char *cityName; struct sCityL...

When teaching C, is it better to teach arrays before or after pointers?

For those of you with curriculum development experience: what is the best strategy regarding arrays? I have seen some schools that teach arrays after variables and control structures, often before even teaching functions. This allows teaching of some rudimentary algorithms, etc. However, it then brings the problem of how to pass arrays ...

Best data structure in C for these two situations?

I kinda need to decide on this to see if I can achieve it in a couple of hours before the deadline for my school project is due but I don't understand much about data structures and I need suggestions... There's 2 things I need to do, they will probably use different data structures. I need a data structure to hold profile records. Th...

How to generate simple 2D graphics in real time?

For my internship on Brain-Computer Interfacing I need to generate some very fast flickering squares on a CRT monitor (flickering = alternating between two colors). The monitor's refresh rate is 85Hz and we would like this to be the bottleneck, which means that repainting all squares can take at most 1000/85 = 11ms. My language of prefe...