0
I wrote this code to make switch
between the letters of a string, but it doesn’t even print anything, someone can explain to me why?
Code:
#include <stdio.h>
#include <string.h>
int main()
{
char *p, *p1, p2;
char str[10];
fgets (str, 10, stdin);
p=str;
p1=str;
while (*p1 != '\0')
{
p1++;
}
while (p!=p1)
{
p2=*p;
*p=*p1;
*p1=p2;
p++;
p1--;
}
printf ("\n%s", str);
return 0;
}
your code is very confusing...put comments in the code explaining what you are trying to do
– zentrunix