c

Brand new to C (how to compile?)

I would like to know what I should use to compile in C. I am brand new to programing in general and would greatly appreciate a comprehensive explanation of this process. I am on Windows Vista. I heard about something called "djgpp" that is free and effective for windows. ...

How to install DJGPP

I am brand new to C and programming. I would like to use DJGPP as my compiler at this point. How can I install it? From what I understand it is multiple files. I cant seem to find a site that actually has the files that has working links. Thank you! I am on Windows Vista. ...

Locked file or directory in C

Hi, I have a daemon that watches a certain file for changes then processes the changes made to the file. But now I've noticed that when I attempt to read the file (using fgets) I get no data. This only happens after a change has been made the file, yet if I attempt to read the file at any other time I can read it fine. I think another...

SQLite C++ Access Columns by Name

Is there a way to access SQLite results by column name (like a C++ Map) instead of index number in C/C++? For example, Python's SQLite access allows dictionary access Results = Query("SELECT * FROM table"); print Results['colname'] print Results['anothercol'] Any similar methods available in C++ for the SQLite's interface? ...

Where to find beta testers for an auto-parallelization tool?

i'm helping a client set up a beta test program for a new auto-parallelization tool, but it's been tricky finding a large-enough set of good testers. we're not looking for QA folks here. we're looking for developers who have an interest in the problem of parallelizing legacy code, in particular in the face of multicore, and who can giv...

Operations from atomic.h seem to be non-atomic

The following code produces random values for both n and v. It's not surprising that n is random without being properly protected. But it is supposed that v should finally be 0. Is there anything wrong in my code? Or could anyone explain this for me? Thanks. I'm working on a 4-core server of x86 architecture. The uname is as follows. L...

C Programming Data Types

A question was asked, and I am not sure whether I gave an accurate answer or not. The question was, why use int, why not char, why are they separate? It's all reserved in memory, and bits, why data types have categories? Can anyone shed some light upon it? ...

C / JSON Library in popular Linux distros?

I have a program written in C that has to input and output JSON over a local domain socket. I've found several C / JSON libraries that 'almost work' through searches. Prior to taking one of the libraries that I found .. I want to be sure that I'm not over-looking a library that is commonly found on modern Linux distros. I'd also really ...

Efficiently convert between Hex, Binary, and Decimal in C/C++

I have 3 base representations for positive integer numbers: Decimal, in unsigned long variable (e.g. unsigned long int NumDec = 200). Hex, in string variable (e.g. string NumHex = "C8") Binary, in string variable (e.g. string NumBin = "11001000") I want to be able to convert between numbers in all 3 representations in the most effici...

How to run my ruby application using ruby extension library (in c), in windows?

Hello, I would be thankful for any help on this: I want to write an extension to my c library. I created file zmq.cpp that uses library libzmq (written in C++). I created makefile using ruby extconf.rb, then I run nmake. It all went fine. Nmake generated files librbzmq-i386-mswin32.def librbzmq-i386-mswin32.lib librbzmq-i386-mswin32...

What are some "good" ways to use longjmp/setjmp for C error handling?

My apologies if this has been address/asked before. I have to use C for one project and I am thinking of using longjmp/setjmp for error handling as I think it will be much easier to handle error in one central place than return codes. I would appreciate if there is some leads on this. I am particularly concerned with resource cleanup ...

Dev C++ to compile C source file

How can I use Dev C++ to compile C source file. I thought it would automatically do it, but for some reason it compiles with several errors and I think its because you have to make changes for it to compile a C file. Example test code: #include <stdio.h> main () { int i,j; double x,x_plus_one(); char ch; i = 0; x = 0; pr...

Maximum CreateProcessWithLogonW and NetUserAdd

I have written a small function that will load multiple instances of an executable using CreateProcessWithLogonW the pseudo-code: for ( i=0;i<100;i++) { sprintf(user,"user%i",i); sprintf(pass,"pass%i",i); if(NetUserGetInfo(user,pass)==NOT_FOUND) { NetUserAdd(user,pass); } aaProcessCreateWithLogin("prog.exe",user,pass); } it wo...

C: Reading a file into an array

Hi to all, I have a text file and i want to to read it line by line and put the lines into an array. The snippet behind gives error while compiling: FILE *f; char line[LINE_SIZE]; char *lines; int num_righe; f = fopen("spese.dat", "r"); if(f == NULL) { f = fopen("spese.dat", "w"); } while(fgets(line, LINE_SIZE, f)) { num_righe++...

After learning C should I consider learning Matlab if my emphasis is on Engineering?

I hear it's the future of engineering, but I'm not entirely sold. What advantages does Matlab provide? Are there any downsides? ...

If and equality statements

I'm trying to solve the problem here but I don't know why my code isn't working. Any help is appreciated. EDIT: Edited to make correction mentioned below, but there is still an extra "15" (in bold) on the second line of the output and I don't understand where it is coming from. My output is 18662658515 555227215 #include <stdlib.h> #...

How to generate a random number in C?

Is there a function or will I have to use a third party library? ...

How to download a file with WinHTTP in C/C++ ?

I know how to download an html/txt page. For example : //Variables DWORD dwSize = 0; DWORD dwDownloaded = 0; LPSTR pszOutBuffer; vector <string> vFileContent; BOOL bResults = FALSE; HINTERNET hSession = NULL, hConnect = NULL, hRequest = NULL; // Use WinHttpOpen to obtain a session handle. hSession = WinHttpOp...

Square root of bignum using GMP

I need to get the square root of a 210 digit number accurately, I thought GMP was the right tool for the job, what am I doing wrong? #include <stdlib.h> #include <stdio.h> #include "gmp.h" int main (int argc, char *argv[]) { mpz_t sq_me, sq_out, test; mpz_init(sq_me); mpz_init(sq_out); mpz_init(test); mpz_set_str (sq_me, argv...

ANSI C compiler for Windows

I'm looking for a good, free C compiler for Windows so I can make some progress on K&R on my 13 hour flight tomorrow. Any suggestions? ...