- 1

Extra terrestrial problem

#include <stdio.h> #include <string.h> int main() { char str[100]; gets(str); int i,length; length=strlen(str); for(i=length;i>=0;i--){ printf("%c",str[i]); } return 0; } This code works in sololearn compiler to reverese a word but does not work in solution code compiler.whats wrong please??

28th Apr 2020, 8:31 AM
Shafiqul Islam
Shafiqul Islam - avatar
1 ответ
+ 2
Hello Shafiqul Islam The index starts at 0. So the last index is length - 1.
28th Apr 2020, 12:32 PM
Denise Roßberg
Denise Roßberg - avatar