2 #include "UART0_stdio.h"
13 unsigned short ent_ushort ;
14 unsigned long ent_ulong ;
32 printf(
"Entrez un char:");
33 scanf(
"%c" , &ent_char);
34 printf(
"%c\n", ent_char);
38 printf(
"Entrez trois caracteres:\n");
39 scanf(
"%3c" , tab_char);
40 printf(
"1er char :%c\n", tab_char[0]);
41 printf(
"2eme char :%c\n", tab_char[1]);
42 printf(
"3eme char :%c\n", tab_char[2]);
44 printf(
"Entrez un nombre decimal positif: ");
45 scanf(
"%d" , &ent_dec_pos);
46 printf(
"%d\n", ent_dec_pos);
48 printf(
"Entrez un nombre decimal negatif: ");
49 scanf(
"%d" , &ent_dec_neg);
50 printf(
"%d\n", ent_dec_neg);
52 printf(
"Entrez un nombre decimal long: ");
53 scanf(
"%ld" , &ent_slong);
54 printf(
"%ld\n", ent_slong);
56 printf(
"Entrez un nombre decimal unsigned long: ");
57 scanf(
"%lu" , &ent_ulong);
58 printf(
"valeur entree: %lu\n", ent_ulong);
60 printf(
"Entrez un nombre decimal unsigned short: ");
61 scanf(
"%hu" , &ent_ushort);
62 printf(
"valeur entree: %lu\n", ent_ushort);
65 printf(
"Entrez un nombre en hexa: ");
66 scanf(
"%x" , &ent_hex);
67 printf(
"%x\n", ent_hex);
69 printf(
"Entrez un nombre en octal: ");
70 scanf(
"%o" , &ent_oct);
71 printf(
"%o \n", ent_oct);
73 printf(
"Entrez un nombre en octal ou hexa (preceder de 0 pour octal et de 0x ou 0X pour hexa), ");
74 scanf(
"%i" , &ent_oct_hex);
75 printf(
"valeur entree en decimal : %i \n", ent_oct_hex);
77 printf(
"Entrez une chaine de caracteres: ");
81 printf(
"Entrez le jour,le mois et l'annee:\n");
83 scanf(
"%d%s%d", &jour, mois, &annee);
84 printf(
"\njour:%d \n",jour);
85 printf(
"mois:%s \n",mois);
86 printf(
"annee:%d \n",annee);
94 printf(
"Entrez une chaine de caracteres en majuscules: ");
95 scanf(
"%[A-Z]" , nom);
98 printf(
"Entrez une chaine de caracteres sans majuscules pour terminer le scanf entrez une majuscule: ");
99 scanf(
"%[^A-Z]" , nom);
100 printf(
"%s \n", nom);
102 printf(
"Entrez une adresse memoire quelconque \n");
104 printf(
"L'adresse %p contient la valeur %d ",ptr,*ptr);
120 printf(
"Entrer un float:\n");
121 scanf(
"%f",&flottant);
122 printf(
"Le float entre est %f",flottant);
124 printf(
"Entrer un double float:\n");
126 printf(
"Le float entre est %Lf\n",f);
129 printf(
"Entrer un nombre avec exposant :\n");
131 printf(
"Le float entre est %le\n",f);
137 printf(
"Entrer un nombre avec exposant :\n");
139 printf(
"Le float entre est %lg\n",f);
141 printf(
"Entrer un nombre avec exposant :\n");
143 printf(
"Le float entre est %Lg\n",fld);
146 f1 = 48656568.256479123456789123456789;
147 f = 48656568.256479123456789123456789;
150 printf(
"Test for Floating points numbers printf\n");
153 printf(
"double :%lf\n",f);
158 printf(
"LONG DOUBLE :%Lf - %20.10Lf - %20.15Lf - %20.20Lf - %30.30Lf\n", f1, f1, f1, f1, f1);
159 printf(
"float2 :%4.2f %+.0e %E \n", 3.1416, 3.1416, 3.1416);
163 printf(
"float3 :%7.3f\n", 1.2345);
164 printf(
"float3bis :%7.3lf\n",4865.256479 );
165 printf(
"float4 :%10.3f\n", 1.2345e3);
166 printf(
"float5 :%10.3f\n", 1.2345e7);
167 printf(
"float6 :%12.4e\n", 1.2345);
168 printf(
"float7 :%12.4e\n", 123.456789e8);
169 printf(
"float8 :%15.5lf\n",48656568.256479 );
170 printf(
"float9 :%15.6lf\n",48656568.256479 - 48656568.256478 );
171 printf(
"float9bis :%-15.6lf%7.4f\n",48656568.256479 - 48656568.256478,1.2345 );
172 printf(
"float9ter :%15.2lf\n",f2*f3 );
187 printf(
"float10 :01234567 \n" );
188 printf(
"float11 :%8g|\n", 12.34 );
189 printf(
"float12 :%8g|\n", 1234.5678 );
190 printf(
"float13 :%8g|\n", 0.0478 );
191 printf(
"float14 :%8g|\n", 422121.0 );
192 printf(
"float15 :%8g|\n", 422121234.345345 );
204 printf(
"float16 :%.0f|\n", 1000.123456789123456789 );
205 printf(
"float17 :%.1f|\n", 2000.123456789123456789 );
206 printf(
"float18 :%.2f|\n", 3000.123456789123456789 );
207 printf(
"float19 :%.10f|\n", 4000.123456789123456789 );
208 printf(
"float20 :%.30f|\n", 5000.123456789123456789 );
209 printf(
"float21 :%f|\n", 6000.123456789123456789 );
210 printf(
"float22 :%.f|\n", 7000.123456789123456789 );
227 char stg[50]=
"chaine" ;
231 printf(
"Test suite de int: \n a=%d\na+1=%d\na+2=%d\na+3=%d\na+4=%d\na+5=%d\na+6=%d\na+7=%d\na+8=%d\na=%d\n",a,a+1,a+2,a+3,a+4,a+5,a+6,a+7,a+8,a);
235 printf(
"Test suite de floats: \nft=%f\nft+0.1=%f\nft+0.01=%f\nft+0.001=%f\nft+0.0001=%f\nft+0.00001=%f\n",ft,ft+0.1,ft+0.01,ft+0.001,ft+0.0001,ft+0.00001);
245 printf(
"Test avec plusieurs formats:\na=%d\nc=%c\nstg=%s\nft=%6.5f\ndb=%10.2e\nhex=%x\n",a,c,stg,ft,db,hex);
246 printf(
"Entrez dans l'ordre un int\n un char\n une chaine\nun float\nun float avec exposant\nun hexa \n");
247 scanf(
"%d%c%s%f%le%x",&a,&c,stg,&ft,&db,&hex);
248 printf(
"Test avec plusieurs formats apres un scanf:\n a=%d\nc=%c\nstg=%s\nft=%6.5f\ndb=%10.2le\nhex=0x%x\n",a,c,stg,ft,db,hex);