Page 1 of 1

byte copy/reverse function for Game A Gogo

PostPosted: Tue Jul 10, 2007 7:35 pm
by Sgt. Sparky
here is the function Game A Gogo. :D
Code: Select all
char smpl[255];
void sample(char s[255])
{
    strcpy(smpl, s);
}
void printsample(char s[255])
{
    strcpy(s, smpl);
}
void reverse(char s[255])
{
     int c, i, j;
     sample(s);
     for(i = 0, j = strlen(smpl)-1; i < j; i++, j--) {
           c = smpl[i];
           smpl[i] = smpl[j];
           smpl[j] = c;
                                                     }
      printsample(s);
}
void bytecpy(char chvar[255])
{
    strncpy(tempe, &chvar[0], 1);
    strcat(newchar[0], tempe);
    strncpy(tempe, &chvar[1], 1);
    strcat(newchar[0], tempe);
    strncpy(tempe, &chvar[2], 1);
    strcat(newchar[1], tempe);
    strncpy(tempe, &chvar[3], 1);
    strcat(newchar[1], tempe);
    strncpy(tempe, &chvar[4], 1);
    strcat(newchar[2], tempe);
    strncpy(tempe, &chvar[5], 1);
    strcat(newchar[2], tempe);
    strncpy(tempe, &chvar[6], 1);
    strcat(newchar[3], tempe);
    strncpy(tempe, &chvar[7], 1);
    strcat(newchar[3], tempe);
    reverse(newchar[0]);
    reverse(newchar[1]);
    reverse(newchar[2]);
    reverse(newchar[3]);
}

you know how to put it in global,
to use this after you put it in global just use on any event
Code: Select all
bytecopy(text);//or whatever other source.

I could have made the function alot simpler, but I wanted to work fast. :(
(limited time)

PostPosted: Tue Jul 10, 2007 9:36 pm
by Fuzzy
Sparky is a genius. i was trying to teach gogo how to do that with bit operators, and i totally looked over the fact that they could be used as text.

PostPosted: Wed Jul 11, 2007 12:11 am
by Game A Gogo
Ok, I will defenetly give it a try! Even if this confuses me a little xD

PostPosted: Wed Jul 11, 2007 12:15 am
by Game A Gogo
There are about two variable that are not declared and it causes error, and I dunno how to declare them :/

PostPosted: Wed Jul 11, 2007 2:20 am
by Sgt. Sparky
I IM'd you on how to declare them.

and thanks Fuzzy. :D