Name: Anonymous 2012-10-29 12:00
Why does "printf("%c, reverse")" just put out "aggiN", but ("%s, reverse") outside of the loop put out "aggiNNigga" when it should do the same?
int main(int argc , char* argv [ ] ) {
int i=0;
int c;
int a=0;
char string[]="Nigga";
char reverse[20];
i=sizeof(string);
printf("%d\n", (i-1));
for(c=i-2;c>=0;c--)
{
reverse[a]=string[c];
printf("%c", reverse[a]);
a++;
}
printf("\n%s", reverse);
return 0;
}
int main(int argc , char* argv [ ] ) {
int i=0;
int c;
int a=0;
char string[]="Nigga";
char reverse[20];
i=sizeof(string);
printf("%d\n", (i-1));
for(c=i-2;c>=0;c--)
{
reverse[a]=string[c];
printf("%c", reverse[a]);
a++;
}
printf("\n%s", reverse);
return 0;
}