projprog/C7.6.c
2021-10-18 08:24:56 +02:00

17 lines
367 B
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <stdio.h>
#define N 10
int main(){
char s[N];
printf("Entrez votre pseudo\n");
if(fgets(s, N, stdin)==NULL)
return 1;// Une erreur est survenue lors de la lecture (trop long ?)
// On doit supprimer le retour à la ligne qu'a capturé fgets.
int i;
for(i=0;i<N && s[i]!='\n';i++){}
s[i] = '\0';
printf("Résultat: %s\n", s);
return 0;
}