c

Standard data structure library in C?

I am looking for standard tried and tested library in C language (Windows platform) which implements data structures like stacks, queues, trees etc. I would prefer to have a source code along with it. Writing a library on my own is possible; however, I feel it may be better to opt for some industry standard implementation which may be o...

Dealing with system time changes

I want to know the time that has passed between the occurrence of two events. Now, the simple way would be to use something like: time_t x, y; x = time(NULL); /* Some other stuff happens */ y = time(NULL); printf("Time passed: %i", y-x); However, it is possible that the system time is changed between these two events. Is there an...

Why does glib redefine types?

What is the reasoning behind types to be redefined in glib? Why do they turn char into gchar, int into gint etc. ? ...

Need To Build Simple DNS Resolver in C

As the title says I need to build a simple dns resolver in C... Not in C++, I have looked on internet for some tutorials to help me get going but mostly find C++. Wondering whether anyone knows of a tutorial to get me started or can give me a couple of tips on how to build my DNS request header in C... Any help will be much appreciat...

Opening gzipped files for reading in C without creating temporary files

Hello, I have some gzipped files that I want to read in C via fopen and fscanf. Is there anyway to do this without having to gunzip the files to temporary files? Thanks. ...

create an independent hidden process

I'm creating an application with its main window hidden by using the following code: STARTUPINFO siStartupInfo; PROCESS_INFORMATION piProcessInfo; memset(&siStartupInfo, 0, sizeof(siStartupInfo)); memset(&piProcessInfo, 0, sizeof(piProcessInfo)); siStartupInfo.cb = sizeof(siStartupInfo); siStartupInfo.dwFlags = STARTF_USESHOWWINDOW | ...

Weird Scanf Issue

I am trying to finish a homework program that compares a string with a text file, so the user can essentially search the text file for the search term (string) in the file. I'm getting there :) However today I'm running into a very weird issue. When it asks for the term to search for I input the text, but it never ends. I could type all...

How can I programmatically create PowerPoint presentations. On Linux. For Free.

I'd like to create a PowerPoint (not Javascript/HTML/PDF/Keynote/.mov) using code (any language, C preferred) for free. (I've seen this SO question which references how to create them in C#) Is this even possible? How can I write the raw bits that make up a PowerPoint file? Any good libraries for doing this? UPDATE The Microsoft Refer...

Recursive binary to decimal function without pow() or loops

I am doing a C course. I need to do a recursive XOR binary but I have some limitations. I can't use loop or any math.h functions, nor can I call another function from the XOR function. This is the function prototype: int binaryXor(int firstnumber[], int secondnumber[], int length); where firstnumber and secondnumber are arrays with t...

union versus void pointer

What would be the differences between using simply a void* as opposed to a union? Example: struct my_struct { short datatype; void *data; } struct my_struct { short datatype; union { char* c; int* i; long* l; }; }; Both of those can be used to accomplish the exact same thing, is it better t...

Reading from a textfile into an array into the C programming language

How do I read into an array a string with space in it, delimited with semicolons from a textfile in the C programming language? ***from textfile*** "My Record; My Second Record; My Third" . . . fopen ... for(i = 0; i < 3; i++) { fscanf_s(myFile, "%s", myRecords[i].title); /* this want read the records */ } fclo...

How to encode PNG to buffer using libpng?

I'm currently using the following to write a PNG to a file: #include <png.h> #include <stdio.h> #include <stdlib.h> #include <stdint.h> /* Pixels in this bitmap structure are stored as BGR. */ typedef struct _RGBPixel { uint8_t blue; uint8_t green; uint8_t red; } RGBPixel; /* Structure for containing decompressed bitmaps. ...

GCC options to enforce Ansi C standard check?

What gcc options shall I use to enforce ANSI C (C99) warnings/errors? gcc (GCC) 3.4.2 (mingw-special) I'm using: gcc -pedantic -ansi -std=c99 is this correct? ...

gdb 7.0, signal SIGCONT doesn't break from a pause() call.

I'd built a version of gdb 7.0 for myself after being pointed to a new feature, and happened to have that in my path still. Attempting to step through some new code, I'd added a pause() call, expecting to be able to get out like so: (gdb) b 5048 Breakpoint 1 at 0x2b1811b25052: file testca.C, line 5048. (gdb) signal SIGCONT Continuing ...

Design code to fit in CPU Cache?

When writing simulations my buddy says he likes to try to write the program small enough to fit into cache. Does this have any real meaning? I understand that cache is faster than RAM and the main memory. Is it possible to specify that you want the program to run from cache or at least load the variables into cache? We are writing si...

How to sniff the number of records in a binary file before reading into an array in the C programming language?

How do I tell in a better way how many records there are in a binary file before I open up the file and read the records into an array for example? MyFile = fopen("DATA.dat", "rb"); i = 0; while (feof(MyFile) == 0) { fread(&tempReadingRecord,sizeof(tempReadingRecord), 1, file); if (feof(MyFile) == 0 { i++; } } fclo...

determine if a process is dead or not - by PID

I have two different way to check whether a process is still up and running: 1) using GetExitCodeProcess() 2) walking the list of processes using CreateToolhelp32Snapshot() and checking PIDs now, in both cases I'm still getting that a process that I terminated with TerminateProcess is till alive even tho it is not. Is there a way to ...

How can I share HWND between 32 and 64 bit applications in Win x64?

MSDN tells me that handles to windows (HWND) can be shared between 32- and 64-bit applications, in Interprocess Communication (MSDN). However, in Win32 a HWND is 32 bits, whereas in 64 bit Windows it is 64 bits. So how can the handles be shared? I guess the same question applies to handles to named objects such as mutexes, semaphores ...

Load XML into C++ MSXML from byte array

I'm receiving XML over a network socket. I need to take that XML and load it into the DOM to perform further operations. MSXML requires input strings that are in either UCS-2 or UTF-16 and completely ignores the XML header with the encoding type when loading from a string. It allows the loading of XML fragments, so this makes some sense....

How to implement dependency checking for C/C++ sources

I started adding support for a 3rd party toolchain (IAR Compiler) to Visual Studio 2005. So far I've managed to implement the required msbuild tasks (Compile, Link and Assemble) and the Visual Studio Add-in to support the *.proj file. The next hurdle is handling dependencies for the headers. I'm not sure what the best way to go about t...