Making a program type

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Oct 2009
Posts: 12
Reputation: geg13 is an unknown quantity at this point 
Solved Threads: 0
geg13 geg13 is offline Offline
Newbie Poster

Making a program type

 
0
  #1
Oct 24th, 2009
I would like help with making a program 'type' out the text as the program is running i.e. not having the entire line appear at once but letter by letter.
Last edited by geg13; Oct 24th, 2009 at 1:35 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,660
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1500
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning
 
-7
  #2
Oct 24th, 2009
put a system pause between letters. Assuming you are coding on MS-Windows.
  1. #include <windows.h>
  2. ...
  3. ...
  4. string msg = "This is a test";
  5. for(int i = 0; i < msg.length(); i++)
  6. {
  7. cout << msg[i]; cout.flush();
  8. sleep(1000); // delay 1 second
  9. }
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 12
Reputation: geg13 is an unknown quantity at this point 
Solved Threads: 0
geg13 geg13 is offline Offline
Newbie Poster
 
0
  #3
Oct 24th, 2009
I had thought of that but then i thought about the fact that my program has string values on pretty much every second line. Those values are user input and i don't know how i would make them do the same as the rest of the program.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,660
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1500
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning
 
-7
  #4
Oct 24th, 2009
make a function out of that code then send the strings to it.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 12
Reputation: geg13 is an unknown quantity at this point 
Solved Threads: 0
geg13 geg13 is offline Offline
Newbie Poster
 
0
  #5
Oct 24th, 2009
Could you please explain it in a simpler manner or provide an example? I've just started learning c++
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,660
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1500
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning
 
-7
  #6
Oct 24th, 2009
  1. void foo(const char* str)
  2. {
  3. // display the string contents here
  4. }
  5.  
  6. int main()
  7. {
  8. foo("Once upon a time ...");
  9. foo("there were three little pigs.");
  10. // etc etc
  11. }
Last edited by Ancient Dragon; Oct 24th, 2009 at 2:09 am.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 12
Reputation: geg13 is an unknown quantity at this point 
Solved Threads: 0
geg13 geg13 is offline Offline
Newbie Poster
 
0
  #7
Oct 24th, 2009
I think i should ask at a later date when i know a bit more about c++ because i want to know what the code does... but thanks for the help anyways
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 272 | Replies: 6
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC