c

cos result incorrect

I import "math.h". I can use the cos function, but when I execute cos(0.321139585333178) the result is 0.948876 If I use the calculator in Mac or use a normal calculator, the result is 0.999984292347418 Can anyone help me to solve that problem? ...

difference between #define and enum{} in C

Possible Duplicate: Difference between Enum and Define Statements when should one use enum {BUFFER = 1234}; over #define BUFFER 1234 ? what are the advantages enum brings compared to #define? i know, that #define is just simple text substitution and enum names the constant somehow. but why would one need that at al...

Need for prefixing a function with (void)...

Hi All, I recently came across a rather unusual coding convention wherein the call for a function returning "void" is prefixed with (void). e.g. (void) MyFunction(); Is it any different from the function call like: MyFunction(); Has it got any advantage or is it yet another needless but there coding convention of some...

Encrypting password in compiled C or C++ code

Hello!, I know how to compile C and C++ Source files using GCC and CC in the terminal, however i would like to know if its safe to include passwords in these files, once compiled. For example.. i check user input for a certain password e.g 123, but it appears compiled C/C++ programs is possible to be decompiled. Is there anyway to com...

Fetching gtk theme background color

Hi there, I'm almost a gtk newbie, and I'm looking for a way to get the background color for the current theme in gtk. So this code: GdkColor color = gtk_widget_get_style(mainWindowHandle)->bg[GTK_STATE_NORMAL]; works only after the main window is shown, before returns an strange ugly gray. ...

Corrupted mysql table, cause crash in mysql.h (c++)

i've created a very simple mysql class in c+, but when happen that mysql crash , indexes of tables become corrupted, and all my c++ programs crash too because seems that are unable to recognize corrupted table and allowing me to handle the issue .. Q_RES = mysql_real_query(MY_mysql, tmp_query.c_str(), (unsigned int) tmp_query.size()); ...

Best way to create a C String

Hello, I'm currently using char *thisvar = "stringcontenthere"; to declare a string in C.. Is this the best way to declare a string? ...

method vs function vs procedure vs class ?

I know the basics of this methods,procedures,function and classes but i always confuse to differentiate among those in contrast of Object oriented programming so please can any body tell me the difference among those with simple examples ? ...

scanf("%d", char*) - char-as-int format string?

What is the format string modifier for char-as-number? I want to read in a number never exceeding 255 (actually much less) into an unsigned char type variable using sscanf. Using the typical char source[] = "x32"; char separator; unsigned char dest; int len; len = sscanf(source,"%c%d",&separator,&dest); // validate and proceed....

Licensing c program

Hi, How would i licence my c command line program, e.g limited functionality without a serial number? ...

What is a C header file?

Possible Duplicate: What are the point of header files in C? Hi, What is a C header file? Is there an alternative just to include more c code? ...

Mac C run in window

Hello, Is it possible to run compiled C and C++ Files on a mac without opening and running it in terminal? E.G is there a separate GUI i can use for executing compiled c programs? ...

Open internet explorer window in C?

Hello, In c/c++ in windows, how do i open a website using the default browser.. in mac os x, i do system("open http://url"); ...

Modbus driver: C vs Java

Hi stackoverflow, I am soon going to start a project where I'm required to program a Modbus driver. My initial approach was to want to do it in Java, however my boss has had contact with a company that has experience in Modbus, and they said C is the better language to approach Modbus. So my boss pretty much demanded it to be in C. My C...

steganography library in C or Obj-C

Hey, Does anyone know of a good steganography library I can use thats written in C or Objective-C? It would need to be used in a Mac OS X application. ...

"Use of uninitialised value" despite of memset

Hi there, I allocate a 2d array and use memset to fill it with zeros. #include<stdio.h> #include<string.h> #include<stdlib.h> void main() { int m=10; int n =10; int **array_2d; array_2d = (int**) malloc(m*sizeof(int*)); if(array_2d==NULL) { printf("\n Could not malloc 2d array \n"); exit(1); } ...

Objective-C NSMutableArray - foreach loop with objects of multiple classes

Hi, I have the NSMutableArray *children in the datastructure-class "Foo" which is the superclass of many others, like "Bar1" and "Bar2". That array stores Bar1 and Bar2 objects to get a tree-like recursive parent-children-structure of subclasses from Foo. To access the objects in the array, I loop through them using the foreach loop in ...

Query on the scope of local variables in C

All, Consider the following code: void func(void) { int a; printf ("%d", a); } int main(int argc, char **argv) { int a = 3; func(); printf("%d", a); } According to my understanding, the output should be: <junk value><3> Can anyone please confirm my understanding? My basic query is, does the compiler refer to t...

What you can't do in C that you can do in Objective-C?

What you can't do in C (C99 standard) that you can do in Objective-C? (with code example if you please) ...

Embedded linux call using system

I'm having a problem using system("command") call in C on an embedded system in linux. The call to the app works fine on the command line but when called in a compiled cgi script using the system command it is painfully slow. Any help appreciated? ...