0

#include <stdio.h> int main() { int i,n; char a[100]; gets(a); n=strlen(a); for(i=0;i<=n;i++) { printf("%s",a[n-i]); }

What is the mistake

2nd Dec 2021, 2:10 PM
Karthik C
Karthik C - avatar
2 odpowiedzi
+ 3
1. To use string method(strlen) you need to include "string.h" library. 2. Use fgets() instead of gets(). You can learn more about this in C lesson https://www.sololearn.com/learning/2936/ 3. a[n-i] means single character not string, so change "%s" to "%c" Hope this helps!
3rd Dec 2021, 1:30 AM
Azhagesanヾ(✿)
Azhagesanヾ(✿) - avatar
+ 1
Please follow this guide on how to post a question https://www.sololearn.com/Discuss/333866/?ref=app
2nd Dec 2021, 3:07 PM
Ipang