I'm pretty very relatively new to C, I'm trying to reverse a string with this code and it works until a word with 8 or more letters is entered and I don't quite understand why.
int main()
{
char string[50], newString[50];
int end, x;
printf("Enter a string: \n");
scanf("%50s", string);
end = strlen(string);
printf("%d\n", end);
for(x=0; x < end; x++){
newString[(end - 1) - x] = string[x];
}
printf("%s", newString);
}
little bit strange wording of the question but it wouldn't let me ask the question since 'my title was too similar to other questions asked' even I have looked and haven't found what I want to know.