Skip to content

Instantly share code, notes, and snippets.

@Adobe-Android
Created February 10, 2019 01:52
Show Gist options
  • Save Adobe-Android/11bc4ad3966390fe81bb75e027932fec to your computer and use it in GitHub Desktop.
Save Adobe-Android/11bc4ad3966390fe81bb75e027932fec to your computer and use it in GitHub Desktop.
C string reversal
int main()
{
char s[20], r[20];
int begin, end, count = 0;
printf("Input a string\n");
scanf("%s", s);
// Calculating string length
while (s[count] != '\0')
count++;
end = count - 1;
for (begin = 0; begin < count; begin++) {
r[begin] = s[end];
end--;
}
r[begin] = '\0';
printf("%s\n", r);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment