1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#include<stdio.h>
#define MAXLIGNE 1000
int max;
char ligne[MAXLIGNE];
char pluslongue[MAXLIGNE];
int lireligne();
void copier();
main(){
int l;
max=0;
while((l = lireligne()) > 0)
printf(" test1, l = %d \n", l);
if(l > max){
printf(" test 2\n");
max = l;
copier();
printf(" test 3\n");
}
if(max > 0){
printf("%s\n",pluslongue);
printf(" test 2\n");
}
return 0;
}
int lireligne(void){
int c, i;
for(i=0;i<MAXLIGNE-1 && (c=getchar())!=EOF && c != '\n'; ++i)
ligne[i]=c;
if(c=='\n'){
ligne[i] = c;
++i;
}
ligne[i]='\0';
return i;
}
void copier(void){
int i;
while((pluslongue[i] = ligne[i]) != '\0')
++i;
} |
Partager