next up previous
Next: Arithmétique Up: Mémento C - shell, Previous: Tableaux taille variable

Entrées/Sorties

Entrées/Sorties
#include <stdio.h>
 
printf("%d %f %c %s\n",i,x,c,s);
scanf("%d %lf %c %s",&i,&x,&c,s);
program < data > out
#include <stdio.h>
...
FILE *in,*out;
in=fopen("data","r");
if (!in) {
printf("erreur de lecture\n");
exit(1);
}
...
fscanf(in,"%d %lf %c %s",&i,&x,&c,s);,
...
fclose(in);
...
out=fopen("out","w");
if (!out) {
printf("erreur d'écriture\n");
exit(1);
}
...
fprint(out,"Résultats: %d %lf\n",n,y);,
...
fclose(out);
#include <stdlib.h>
int main(int argc, char argv[])
{
char name[32];
int n;
double x;
if (argc != 4) {
printf("Syntax: %s name n x\n",argv[0]);
exit(1);
}
strcpy(name,argv[1]);
n=atoi(argv[2]);
x=atof(argv[3]);
...
}

next up previous
Next: Arithmétique Up: Mémento C - shell, Previous: Tableaux taille variable
R.Keriven (Cermics)