datatypes in C
Yes not python(we already know about that) lets study C : a mini intro
So i was initially having this doubt what is the difference between char and string ? reff: www.sanfoundary.com
A character is just a single character enclosed in single quotes for example :
char initial = 'a';
And a character string is a sequence of 0 or more characters enclosed in double quotes. Each string is terminated by a NULL byte. Therefore string containing 0 character is called an empty string.
example :
char str[] ="How you doin";
char msg[11] = "hello dear";
// for a string containing max 10 characters we have to declare a character array of size 11 bytes.
//i.e. for the last NULL byte for termination
Data-types in C :
Data Type Memory (bytes) Range Format Specifier
short int 2 -32,768 to 32,767 %hd
unsigned short int 2 0 to 65,535 %hu
unsigned int 4 0 to 4,294,967,295 %u
int 4 -2,147,483,648 to 2,147,483,647 %d
long int 4 -2,147,483,648 to 2,147,483,647 %ld
unsigned long int 4 0 to 4,294,967,295 %lu
long long int 8 -(2^63) to (2^63)-1 %lld
unsigned long long int 8 0 to 18,446,744,073,709,551,615 %llu
signed char 1 -128 to 127 %c
unsigned char 1 0 to 255 %c
float 4 %f
double 8 %lf
long double 12 %Lf
So i was initially having this doubt what is the difference between char and string ? reff: www.sanfoundary.com
A character is just a single character enclosed in single quotes for example :
char initial = 'a';
And a character string is a sequence of 0 or more characters enclosed in double quotes. Each string is terminated by a NULL byte. Therefore string containing 0 character is called an empty string.
example :
char str[] ="How you doin";
char msg[11] = "hello dear";
// for a string containing max 10 characters we have to declare a character array of size 11 bytes.
//i.e. for the last NULL byte for termination
Comments
Post a Comment