Animated text

This is a discussion on Animated text within the C++ Programming forums, part of the General Programming Boards category; Hi! I wanted to know how to have animated text, like displaying each letter at a different time. Please can ...

  1. #1
    Registered User stuart_cpp's Avatar
    Join Date
    Apr 2006
    Location
    UK
    Posts
    31

    Animated text

    Hi!
    I wanted to know how to have animated text, like displaying each letter at a different time.
    Please can u telll me!
    Last edited by stuart_cpp; 07-08-2006 at 01:17 PM.

  2. #2
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    Well, if you have the text saved in a string, you could do something like this:

    Code:
    string 	Text 	= "***ANIMATION***";
    int 	Len	= Text.size();
    
    for ( int i=0; i<Len; i++ )
    {
    	cout<< Text[i];
    }
    It's simply a loop, displaying one character at a time.

  3. #3
    Registered User stuart_cpp's Avatar
    Join Date
    Apr 2006
    Location
    UK
    Posts
    31
    Thanks so much twomers!!

  4. #4
    Registered User L_U_K_E's Avatar
    Join Date
    Apr 2006
    Posts
    106
    I was told you should really type
    Code:
    for ( int i=0; i !=Len; i++ )
    instead for good measure.Dont really know why but hey.

  5. #5
    Registered User
    Join Date
    Nov 2005
    Posts
    545
    I don't see how that is better for good measure as if there was some fault and it jumped about the value of int Len then it would keep going.

  6. #6
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    I think the != thing is needed for vectors and whatnot, but I don't really think it makes a difference. It yeilds the same effect, and what bumfluff said holds a lot of ground!

  7. #7
    Registered User
    Join Date
    Nov 2005
    Posts
    545
    I know

  8. #8
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,579
    It's not a requirement to do so. It's more an issue of good practice.

    While probably open for debate, it is preferable to deal with the != operator instead of < or <= operators in for loop headers. This is so because generic algorithms for standard container types are much more picky in the choices we can make for operators. And loops are usually controlled with the != operator. As such, in an effort to maintain a single coding style across our program (and our programs), it is best one gets used to the != operator.

    There is another reason... more debatable. And that is simply, it makes more sense to use != instead of < because it better captures the step nature of this type of loops.

    Overall, it is a matter of preference. But do consider the shift to !=. It will pay later on.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  9. #9
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,579
    Quote Originally Posted by bumfluff
    I don't see how that is better for good measure as if there was some fault and it jumped about the value of int Len then it would keep going.
    The same for <= or < operators. Don't you think?
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  10. #10
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    Or couldn't you just use each when they are needed? I think for a 'for' loop, the '<' / '<'defines the acceptable scope for the loop better than the '!=' does ... if you know what I mean.

  11. #11
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,579
    As I said, it is debatable... unless, you are using generic algorithms. On that case, you don't have a choice.

    The underlying principle is thus consistency in our choices. This should always be our primary motivation.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  12. #12
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Quote Originally Posted by Mario F.
    The same for <= or < operators. Don't you think?
    Is's much safer I woud say. With < or <= it can never be out of bounds even if there is a mistake in the increment .
    Kurt

  13. #13
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,579
    Quote Originally Posted by ZuK
    Is's much safer I woud say. With < or <= it can never be out of bounds even if there is a mistake in the increment .
    Kurt
    Really?
    Do provide an example in which the choice of those operators would break in one instance and not on another.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  14. #14
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    Code:
    for ( int i=0; i<10; i++ )
    {
     i+= 12;
    }
    Code:
    for ( int i=0; i!=10; i++ )
    {
     i += 12
    }

  15. #15
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Quote Originally Posted by Mario F.
    Really?
    Do provide an example in which the choice of those operators would break in one instance and not on another.
    this will only write to buffer[0] and buffer[2];
    Code:
    char buffer[3];
    for ( i = 0; i < sizeof(buffer); ++i ) {
       buffer[i]=0; 
       ++i ; by mistake;
    }
    this will segfault for shure
    Code:
    char buffer[3];
    
    for ( i = 0; i != sizeof(buffer); ++i ) {
       buffer[i]=0; 
       ++i ; by mistake;
    }
    Kurt

Page 1 of 3 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Deleting Text from a Text file
    By Daved in forum C++ Programming
    Replies: 5
    Last Post: 11-04-2006, 09:47 PM
  2. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 04:49 PM
  3. Appending text to an edit control
    By dit6a9 in forum Windows Programming
    Replies: 3
    Last Post: 08-13-2004, 10:52 PM
  4. Scrolling The Text
    By GaPe in forum C Programming
    Replies: 3
    Last Post: 07-14-2002, 05:33 PM
  5. Replies: 1
    Last Post: 07-13-2002, 06:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21