Sunday, August 2, 2009

C questions?

I was doing some Game Boy Advance programming in C (not C++) and was confused on some things.


What exactly do these functions do?





unsigned signed short long void char

C questions?
The keywords you list are not "functions". They are data types for variables.





For example





char letter = 'k';


The line above stores the letter k into the variable named "letter". Since k is a single character is must go into a variable designed to hold just one character. "char" signifies this.





data types that hold whole numbers are short, int, long


data types that hold real numbers are float and double





Depending on the compiler you use the size of a short, int, and long can differ. In general sizeof( short ) %26lt; sizeof( int) %26lt; sizeof( long)





The keywords "signed" and" unsigned" are used in conjunction with short, int, long, float and double. They indicate whether the variable is meant to hold negative numbers or not.





examples


signed float a = -5.23434; // or a positive number


unsigned float foo = 5.234; // no negaive numbers allowed!


signed int = 6.23; // or a negative number


unsigned int = 234; // no negaive numbers allowed!





void is a bit special. You can't declare a variable of type void as in:


void foo = {somevalue} // not allowed!





You can declare a pointer to void as in:


void* ptr = {address of some varible, eg %26amp;foobar}





void is also used in function definitions to indicate no return type and no parameters. For example:





void DrawSomething( void );


This function takes no parameters and returns no parameters and void indicates this. The void in the parenthesis is optional.
Reply:http://yepoocha.blogspot.com


might help Report It

Reply:unsigned signed short long void char are data types meaning the size of the varibale , consider char x , then x can store one charachter only , void means empty or nothing , it varies where you write it.


%26amp;x is a varible that pointing to some other place in memory ,


; you have to end c statements with ;
Reply:check out http://www.pscode.com for great examples.

survey results

No comments:

Post a Comment