Hello
I want to swap array elements as shown in following image without any library, sizeof operator and extra array
H
E
L
L
O
OLLEH
I was expecting print statement should be print "HELLO" but it's only printing the same as before OLLEH. I don't understand why it happens in the code. any idea how to get output as expected
I want to swap array elements as shown in following image without any library, sizeof operator and extra array
C:
#include <stdio.h>
int main()
{
int i = 0;
char name[]= {"OLLEH"};
char *start = &name[0];
char *end = &name[4];
for ( i = 0; i < 5; i++)
{
start = *end ;
printf("%c\n", start);
end--;
}
printf("%s", name);
return 0;
}
E
L
L
O
OLLEH
I was expecting print statement should be print "HELLO" but it's only printing the same as before OLLEH. I don't understand why it happens in the code. any idea how to get output as expected