c

What does the postfix "_t" stand for in C?

Possible Duplicate: What does a type followed by _t (underscore-t) represent? While typing in my IDE (Xcode), autocomplete pops up already-defined words when I'm partway thru entering some variable name. I occasionally see names that have '_t' at the end of them. What naming convention is that and what does it mean? Is ther...

problem with getchar() in C

Well am learning C, and this is probably the stupidest question, but here it comes: I'm using "getchar()" to stop the command windows so I can see the exercises am doing but it just don't work. heres a sample: #include <stdio.h> int main() { int value; printf("1. option 1.\n2. option 2.\n3. option 3.\n4. Exit\n\nMake an option...

What Does Adding One to a Character Array in C Do?

I'm looking through some code for learning purposes. I'm working through this portion of code. // e.g. const unsigned char data={0x1,0x7C ... } unsigned char buf[40]; memset(buf,0,40); buf[0] = 0x52; memcpy(buf+1, data, length); // What does buf+1 do in this situation? On the last line where memcpy is called what does buf+1 do? buf is...

Canny Edge Detector in C

I am looking for a bit of clarification on how the algorithms implemented in Canny edge detection - Wikipedia entry - work. It seems pretty straightforward to perform noise reduction using a 2D Gaussian filter, but I have heard that using two 1D filters - how is this accomplished? It's also simple to calculate the gradient and edge dir...

Floating Point Subtraction in C results zero

I have a code wriiten in C which is intended for a 16-bit microcontroller. The code essentially does lot of floating point arithmatic. The arithmatic works fine till the result is positive; but in case of subtraction if the expected result is negative; I get a zero. result = 0.005 - 0.001; is correctly computed as 0.004 result = 0...

What is a good book to study data structures in C?

Please tell me a good book for studying data structures in C. Feel free to post links of good e-books if you have any. What should be the strategy while learning this topic? ...

How to find the size of a variable with out using sizeof

Let us assume I have declared the variable 'i' of certain datatype (might be int, char, float or double) ... NOTE: Simply consider that 'i' is declared and dont bother if it is an int or char or float or double datatype. Since I want a generic solution I am simply mentioning that variable 'i' can be of any one of the datatypes namely i...

setjmp/longjmp and local variables

My questions aims at the behaviour of setjmp/longjmp concerning local variables. Example code: jmp_buf env; void abc() { int error; ... if(error) longjmp(env); } void xyz() { int v1; // non-volatile; changed between setjmp and longjmp int v2; // non-volatile; not changed between setjmp and longjm...

scope vs ctags in terms of features

I am a big fan of ctags Hence I am wondering if I have cscope, will I benefit more there two programs. Seems like the latter has the same features as ctags, namely, facilitating the finding of symbols. What are the features scope offers that can further increase my productivity with VIM? Thanks ...

Why is sizeof an operator?

Why is sizeof considered an operator and not a function? What property is necessary for something to qualify as operator? ...

compiling C++ static library for 64 bit windows platform using VS2008

ith Visual Studio 2008, If the configuration type is a static library, I dont see a linker option in project properties. I need to specify /MACHINE:x64 option for a static library. I tried to specify this in command line option in Librarian. Only then I could build the static library. If I dont specify /MACHINE compiling the static lib f...

Converting hex string stored as chars to decimal in C

I'm given a string hex_txt containing a 4 digit hex number in the way outlined in the code, split up in two array entries. I need to convert it to decimal. The following is the way I'm doing it. unsigned char hex_txt[] = "\xAB\xCD"; unsigned char hex_num[5]; unsigned int dec_num; sprintf(hex_num, "%.2x%.2x", (int)hex_txt[0], (int)hex_t...

.NET RegEx Performance vs. C++

Is there any published benchmark results about RegEx performance in .NET vs. unmanaged C++/C? ...

detect program termination (C, Windows)

I have a program that has to perform certain tasks before it finishes. The problem is that sometimes the program crashes with an exception (like database cannot be reached, etc). Now, is there any way to detect an abnormal termination and execute some code before it dies? Thanks. code is appreciated. ...

How to tame the Windows headers (useful defines)?

In one of the answers to this question jalf spoke about useful define NOMINMAX, that could prevent from unwanted defining min/max macros. Are there other useful defines that can help to control windows.h (or other Windows headers, for instance Microsoft C Runtime headers or STL implementation) behavior? ...

Simple assembly questions

; int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd) _wWinMain@16 proc near var_4= dword ptr -4 hInstance= dword ptr 4 hPrevInstance= dword ptr 8 lpCmdLine= dword ptr 0Ch nShowCmd= dword ptr 10h From what I can see, the last 4 variables are the parameters passed to the WinMain func...

Create a timer on a different thread - with no callback function (C, Windows)

Is there a way to create a timer (say, to 10 seconds) on a different thread? I mean, I know how to use CreateThread() and I know how to create/use timers. The problem I have is that the new thread cannot receive a callback function. For those that will inevitably ask "why do you want to do this?" the answer is because i have to do it th...

CreateDesktop() with vista and UAC on (C, windows)

I asked this in http://stackoverflow.com/questions/1188396/createdesktop-with-vista-uac-c-windows I set a bounty but in trying to vote down the only answer the "accept" was pressed by mistake (i've been awake for more than 48 hs). so I am asking it again. I'm using CreateDesktop() to create a temporary desktop where an application will...

error using restrict keyword

In the following example: void foo (double *ptr) { const double * restrict const restr_ptr=ptr; } I get this error: error: expected a ";" const double * restrict const restr_ptr=ptr; ^ I compile with -std=c99, using gcc 3.4 Any Ideas? ...

What is exactly the base pointer and stack pointer? To what do they point?

Using this example coming from wikipedia, in which DrawSquare() calls DrawLine(), could anyone explain me what the ebp and esp are in this context? From what I see, I'd say the stack pointer points always to the top of the stack, and the base pointer to the beggining of the the current function? Or what? Thanks edit: I mean this in...