Extra terrestrial problem | Sololearn: Learn to code for FREE!

0

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??

4/28/2020 8:31:44 AM

Shafiqul Islam

1 Answer

New Answer

+2

Hello Shafiqul Islam The index starts at 0. So the last index is length - 1.