1
Answer

Write a program that will reverse the letters in a string. Eg if s1 is assigned "horse" then s2 ends up as "esroh"

Ask a question
sami sam

sami sam

12y
1.1k
1

the output is an empty black screen what I know there is something I did wrong with the loop:

Write a program that will reverse the letters in a string. Eg

                if s1 is assigned "horse" then s2 ends up as "esroh"



#include <stdio.h>

#include <string.h>

char s1[80], s2[80];

int i,j;

int main (){

                strcpy(s1, "hourse");

                i=strlen (s1)-1;

                j=0;

                while(i>=0){

                s2[j]=s1[i];

                i--;

                j--;

                s2[j]='\0';

                }

}


Answers (1)