c

Windows threading: _beginthread vs _beginthreadex vs CreateThread C++

What's a better way to start a thread? I'm trying to determine what are the advantages/disadvantages of _beginthread, _beginthreadex and CreateThread. All of these functions return a thread handle to a newly created thread, I already know that CreateThread provides a little extra information when an error occurs (it can be checked by c...

An interesting C linked list idiom

I was at an interview for a C position in which they presented me with an idiom that I haven't previously encountered. This is a trick that simplifies implementation of various algorithms involving linked lists and I'm wondering if anybody else has encountered this. Say we have a linked list record defined so: typedef struct _record { ...

gartrip calibration file format/generation

I need to generate calibration file* for the Gartrip program. Does anyone known where I can find the file format it uses or, better yet, code for generating them? I'm not to picky on the language. If no one point me at anything better, I'm working on getting some examples to reverse engineer. Shouldn't be to bad as I have reason to exp...

Where can I find an example unzipper using zlib?

I'm looking for a bare bones simple example C app for unpacking a zip file using zlib. It must support fairly new version of .zip and must have source right down to the zlib calls. ...

information on TAP and TDD for 'C'

I am precisely looking for the info like , TAP is for regression and TDD is for Unit Testing ... or are they mutually exclusive( no need to use both of them ) ? bonus for suggesting 'good' Unit Test Frame work for TDD in C (expecting to address good aspect as well :) ) finally cMockery (googles code) for Testing C code (not derived ...

Purpose of: #define, #include, #undef...

Hi All, What would the purpose of this construct in a c file be?: #define _TIMERC #include "timer.h" #undef _TIMERC I am aware of the guard for preventing multiple inclusion of a header file. This doesn't appear to be whats happening though. thanks! ...

new dynamic tools analysis for C-code

Could somebody tell me wich new dynamic tools analysis for C-code are there like valdgrind? ...

Does the Microsoft Visual C++ Express compiler compile C code?

I'm not sure, will the visual c ++ compiler express edition work for compiling c and if not can someone link me to an easy c compiler to use. Thanks in advance. ...

C program that prints out another C program in Japanese

There was a C program written for a contest that was formatted in ASCII art as a Japanese character. When compiled and ran it printed out another program formatted in a different Japanese character, then another, then finally it printed out the first again. I was looking for the code to that and could not find it on the internet. I do...

Console application leaves cmd.exe set size.

I have written a console application that sets the size of the console and output buffer. My problem is that after the program ends I cannot resize my cmd.exe window the way I did before. After the program sets the size of the window it retains that size no matter what I do afterwards. ...

How can I enforce a maximum amount of forked children?

EDIT: I've tagged this C in a hope to get more response. It's more the theory I'm interested in than a specific language implementation. So if you're a C coder please treat the following PHP as pseudo-code and feel free to respond with an answer written in C. I am trying to speed up a PHP CLI script by having it execute its tasks in p...

What does a const pointer-to-pointer mean in C and in C++?

I know the rule-of-thumb to read declarations right-to-left and I was fairly sure I knew what was going on until a colleague told me that: const MyStructure** ppMyStruct; means "ppMyStruct is a pointer to a const pointer to a (mutable) MyStructure" (in C++). I would have thought it meant "ppMyStruct is a pointer to a pointer to a con...

How loader Maps DLL in to Process Address Space

I am curious to know How the Loader Maps DLL in to Process Address Space. How loader does that magic. Example is highly appreciated. Thanks in advance. ...

Why #include <stdio.h> is *not* required to use printf()?

Session transcript: >type lookma.c int main() { printf("%s", "no stdio.h"); } >cl lookma.c Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. lookma.c Microsoft (R) Incremental Linker Version 8.00.50727.762 Copyright (C) Microsoft Corporation. ...

How does one declare an array of constant function pointers in C?

I need to declare an array of pointers to functions like so: extern void function1(void); extern void function2(void); ... void (*MESSAGE_HANDLERS[])(void) = { function1, function2, ... }; However, I want the the array to be declared as constant -- both the data in the array and the pointer to the data. Unfortunately, I do n...

Is there a compiler or IDE for C on Windows that's regarded as an industry standard?

Taking advice from this post, I purchased a copy of 'The C Programming Language' and am happily reading my way through. However, all the stuff I've written in the past has been interpreted, and I have no idea where to look for a good C compiler or an IDE (is there even one?). Google searches throw up a lot of results for C++ compilers, w...

About sleep() in unistd.h

OK I'm just learning C with this book of Kernighan and Ritchie; I'm in the basics of the fourth chapter (functions stuff). The other day I came in curiosity with this function sleep(), so tried to use it like this: #include <stdio.h> #include <unistd.h> int main(void) { printf(" I like cows."); sleep(5); return 0; } The problem...

How to integration-test a network application in C

I've never managed to move from unit-testing to integration-testing in any graceful or automated way when it comes to network code. So my question is: Given a simple single-threaded client/server based network application, how would you go about integrating both client and server into your currently favorite testing suite (I currently u...

Cygwin1.dll 'not found' when running a program written in C. How can I make Windows find it?

So I'm trying to run my first hello world prog written in C. I compiled it in eclipse and get no errors, but when I try to run it I get: "This application has failed to start because cygwin1.dll was not found." I found this post which seems to indicate I should add it to Windows PATH, and I used this to do that. So now "Path" in my env...

How to find out if a pointer is on the stack on PC/Visual C++

[This is for PC/Visual C++ specifically (although any other answers would be quite illuminating :))] How can you tell if a pointer comes from an object in the stack? For example: int g_n = 0; void F() { int *pA = &s_n; ASSERT_IS_POINTER_ON_STACK(pA); int i = 0; int *pB = &i; ASSERT_IS_POINTER_ON_STACK(pB); } so o...