Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Need help fast. I sucks ass at programming.

Name: Anonymous 2009-05-18 22:21

int main()
{
    char s[50], s2[50];
    int i,j;
    printf("type string");
    gets(s);
    for (i=0; s[i]!= '\0'; i++);
    for (j=0; j<i; j++){
        s2[j]=s[i-j];
    }
    puts(s2);

}
 It was suppose to "invert" the string. If I type "abcd" it was supposed to come out as "dcba". I fail at life.
How can I fix this?

Name: Anonymous 2009-05-20 15:14

>>37
no

That makes it longer. In order to successfully use #define to optimize it, you need to make sure the #define replaces at the very least, 11 (#define + 2 spaces + replace character + use of replace character for each instance) + replaced text length characters.

For example, with void, you would need to make sure it replaces no less than 15 characters. That's just to break even. The only things even close to being #define-compatible for optimization in that particular code excerpt are *r--= and char * and even those aren't close to a gain.

It's over; you've lost.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List