Page 1 of 1

Strange "delete" effect in typewritting text? :)

PostPosted: Sun Mar 24, 2013 5:49 am
by Hblade
So heres my code
Code: Select all
void setText(char msg[256])
{
    int i;
    int tmp = strlen(msg);
    while(i<tmp)
    {
        i++;
        strcpy(text, &msg[i]);
        break;
    }
}


When I use this code, the typewritting works lol but it stamps the whole message and deletes it instead of types it

Re: Strange "delete" effect in typewritting text? :)

PostPosted: Sun Mar 24, 2013 8:38 am
by skydereign
First off, why have the loop? The break statement will always break out of it, so just use an if. Second, each time you call that function it increases i by 1, and then sets text equal to the string starting at msg[i]. So when i is equal to 0, it shows the entire string, when i is equal to 1, it shows all but the first letter, and so on.

Re: Strange "delete" effect in typewritting text? :)

PostPosted: Sun Mar 24, 2013 3:13 pm
by Hblade
Alright, I'll use an if statement, and thanks! =) now I know what I have to do... well sort of :) I managed to get it to not go backwards, but instead it types the last letter first haha which is ok I can figure it out from here I think

Thanks sky

Re: Strange "delete" effect in typewritting text? :)

PostPosted: Sun Mar 24, 2013 3:18 pm
by lcl
You could use strcat() for adding the characters to the text one by one.

Re: Strange "delete" effect in typewritting text? :)

PostPosted: Mon Mar 25, 2013 1:47 am
by Hblade
I'm just using yours :P