Source : ct|23.04.08
< Tutorials Computer, Multimedia, Chinese
In C (or in C++) language, the principals data types, indicated hereafter, allow to answer to the great mjority of needs, in matter of characters, strings of characters, bytes or numbers (integers or real numbers)...
1) CHARACTER
char: byte : values -128 to 127 (memory size 1 bytes)
2) STRING
char machaine[] : table of characters, ended with a zero
3) BYTE
unsigned char : byte :values 0 to 255 (memory size 1 bytes)
4) INTEGER
int : values -2.147.483.648 to 2.147.483.647 (memory size 4 bytes)
unsigned int : values 0 to 4.294.967.295 (memory size 4 bytes)
5) REAL NUMBER
float: values 3.4*10-38 to 3.4*1038 (memory size 4 bytes)
double values 1.7*10-308 to 1.7*10308 (memory size 8 bytes)
The printing (or displaying) formats, wich can naturally be associated to those types, when we use the printf() function, are followers :
char : %c to display the character himself, and %d to display the value of the corresponding number
char[]: %s
unsigned char : %d
int : %d
unsigned int : %u
float : %f
double : %lf
#include <stdio.h>
#include <conio.h>
int main()
{
char moncaractere ='A';
char[] machaine="bonjour";
unsigned char monbyte =255;
unsigned int p=17;
int q=-12;
float x=0.557;
double y=15.32;
printf("moncaractere= %c\n",moncaractere);
printf("machaine= %s\n",machaine);
printf("monbyte= %d\n",monbyte);
printf("p= %u\n",p);
printf("q= %d\n",q);
printf("x= %f\n",x);
printf("y= %lf\n",y);
system("pause");
return 0;
}
The obtained result is following :
© http://turrier.fr (2007) |