c

Subtractive blending with OpenGL?

I would like to for example draw shapes A, B, C then set the blender, then draw shape D and everywhere where shape D is, the scene shows my background color of (1,1,1,0). Thanks ...

Is there any difference in C and C++ between using if, else if, else if, ... and using switch () { case A: ... case B: ... } ?

I am interested if there is any difference from the C or C++ compiler perspective whether I use: if (value == a) { ... } else if (value == b) { ... } else if (value == c) { ... } versus switch (value) { case a: ... break; case b: ... break; case c: ... break; }...

Is it possible to use libraries build under VC++ in cygwin gcc build?

I have libraries which are build using VC++. I want to use the same libraries in a program and build in cygwin gcc compiler. Is this scenario will work? ...

Comparing command parameter with argv[] is not working

I am trying to compare the parameter of command with argv[] but it's not working. Here is my code. ./a.out -d 1 In main function int main (int argc, char * const argv[]) { if (argv[1] == "-d") // call some function here } But this is not working... I don't know why this comparison is not working. ...

Implementing Glyph patterns in C

Hii , I have read this implementation of glyphs in the Expert C programming by Peter Van Der Linden . He states this method to draw a glyph pattern.This question is strictly restricted to the context of C programming ... static unsigned short stopwatch[] = { 0x07C6, 0x1FF7, 0x383B, 0x600C, 0x600C, 0xC006, 0xC006, 0xDF06, 0xC106, 0xC10...

Is it always a good practice to set pointers to NULL after free()-ing them?

Possible Duplicate: Setting variable to NULL after free I am learning about good C programming practices and my friend told me to always set the pointers to NULL after free()ing them (or calling a specific freeing function). For example: char* ptr = malloc(100); ... free(ptr); ptr = NULL; or struct graph* graph = create_...

Is there any way to deduce link flags from headers ?

Let's say I know that some of my C/CPP files include certain headers - is there any reliable information against which libraries I will have to link, other than guessing ? For example, if I have something like #include "foo.h" and want to find libfoo_abcdef_123.so Is there any 'best practice' how to do that, any place where to lo...

how to create xml message in c?

My application is written in c, and I need to create some XML messages to send over HTTP. what's the best way to create XML messages? Thanks! ...

shell script to c converter

Does anyone know of any tool which can convert shell script '.sh' into a C file '.c' ? ...

Why doesn't size of struct is equals to sum of sizes of its individual member types?

Possible Duplicate: Why isnt sizeof for a struct equal to the sum of sizeof of each member? I guess similar (duplicate) questions must have been asked on SO before. But I'm unable to find them. Basically I don't know what to search for. So asking it here. Why doesn't size of struct is equals to sum of sizes of its individual...

Seg Fault in Knowledge Tree

I am implementing a knowledge tree in c that can read from a file. I am getting a seg fault in my newStr function. I'm not able to test the rest of my code with this problem. I don't have much experience with c. Any help would be greatly appreciated. my .c file #include #include #include"animal.h" #inclu...

Multiple sockets for clients to connect to

Is it possible to have multiple sockets, which can either by TCP or UDP in one program? For example: SocketOne: TCP socket at port 4567; socketTwo: TCP socket at port 8765; socketThree: UDP socket at 7643. The families will be AF_INET, and addresses will be INADDR_ANY for each. I bind and listen for TCP, and just bind for UDP. What ...

What is wrong with this recursive va_arg code?

Hi, I'm trying to make a generic function taking a variable argument list. A part of the design is that some of these functions call each other. Unfortunately it doesn't seem to work. As you can see if you run the simple code below, the call to command() always fails, but the direct call to marshal_size() succeeds in decoding the two st...

Should functions be made "extern" in header files?

Should functions be made extern in header files? Or are they extern by default? For example, should I write this: // birthdays.h struct person find_birthday(const char* name); or this: // birthdays.h extern struct person find_birthday(const char* name); Thanks, Boda Cydo. ...

What is lib Swscale used for by ffmpeg programers?

What is lib Swscale used for by ffmpeg programers? What benefits it gives for AV encoding/decoding? What is its position relevantly to av* libs? ...

Adding blink to the color but its not blinking

The text should blink in red color but its not blinking #include<stdio.h> #include<conio.h> #include<graphics.h> #include<dos.h> void main(void) { int driver=DETECT,mode,mx,my,x1,y1,x2,y2; initgraph(&driver,&mode,"C:\\tc\\bgi"); cleardevice(); mx=getmaxx(); my=getmaxy(); settextstyle(0,HORIZ_DIR,6); setcolor(RED+BLIN...

How does a C/C++ compiler find the definitions of prototypes in header files?

When I declare a function in a header file, and put the definition of that function in some other file, how does the compiler/linker find the definition? Does it systematically search every file in its path for it, or is there a more elegant solution? This has been bugging me for the past few days, and I've been unable to find an explana...

Implementation of t9 dictionary using tries.

Hi.. I want to implement a t9 prediction dictionary(mobile phones) using tries.I also want to save the entered text in a file.How do I do that?? n Where do I store all the words entered?? Im really confused:(.. Plz help.. ...

Need to get Saturdays date of the week in linux C

I am trying to get Saturday's date of the week in Linux C. Using the function time and localtime, I got today's date and time details. How to proceed further to get Saturday's date? #include <time.h> #include <stdio.h> #include <string.h> int main() { char date[20]; struct tm *curr_tm = NULL; time_t curr_time; curr_time = tim...

what is the meaning of the #define in the objective C?

Hi, everyone, I want to ask a question about the objective C or may be the C language. I want to ask what is the meaning of the following code of #define? Is it like to declare a variable? Thank you. #define kMountainNameString @"name" #define kMountainHeightString @"height" #define kMountainClimbedDateString @"c...