0

What's wrong here?

#include <stdio.h> #include <string.h> int main() { char txt[200]; int L,i; printf("veuillez taper un texte: \n"); gets(txt); L=strlen(txt); for(i=L-1;i>=0;i++) { printf("%c",txt[i]); } return 0; }

9th Feb 2021, 10:46 AM
Lamya Alahyane
Lamya Alahyane - avatar
3 Respostas
+ 6
Remove the first printf, it is not necessary to print texts that aren't required in challenges. Since the program is iterating the char backwards, the incremention should be i-- and not i++. https://code.sololearn.com/cuPDf6R4Nwi5/?ref=app
9th Feb 2021, 10:50 AM
noteve
noteve - avatar
+ 4
And use fgets() instead of gets() fgets(txt, 200, stdin);
9th Feb 2021, 10:57 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Ty it works
9th Feb 2021, 11:18 AM
Lamya Alahyane
Lamya Alahyane - avatar