int main(void) {
char tmp, arr[100];
int i, k;
printf("Enter a string: ");
scanf_s("%s", arr);
for ( k = 0, i = (strlen(arr) - 1); k < (int) (strlen(arr) / 2); --i, ++k) {
tmp = arr[k];
arr[k] = arr[i];
arr[i] = tmp;
}
puts(arr);
return 0;
}
I know that there is something weird about scanf_s() but I could NOT resolve the issue. My code works well by using scanf() but this does NOT reverse the elements of the array :( Any help will be strongly appreciated. Thanks.