Skip to content

Commit

Permalink
Create Reversestringbyword.c
Browse files Browse the repository at this point in the history
  • Loading branch information
raghavkhanna30 authored Oct 15, 2020
1 parent effae11 commit 5b2b7b5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Reversestringbyword.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
char* reverseString(char* input1)
{
int length = strlen(input1);
int i;
for (i = length - 1; i >= 0; i--) {
if (input1[i] == ' ') {

input1[i] = '\0';


printf("%s ", &(input1[i]) + 1);
}
}


printf("%s", input1);
}

int main()
{
char input1[] = "MY NAME IS KHAN";
reverseString(input1);
return 0;
}

0 comments on commit 5b2b7b5

Please sign in to comment.