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.

put a system pause between letters. Assuming you are coding on MS-Windows.

#include <windows.h>
...
...
string msg = "This is a test";
for(int i = 0; i < msg.length(); i++)
{
    cout << msg[i]; cout.flush();
    sleep(1000); // delay 1 second
}

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.

make a function out of that code then send the strings to it.

Could you please explain it in a simpler manner or provide an example? I've just started learning c++

void foo(const char* str)
{
   // display the string contents here
}

int main()
{
   foo("Once upon a time ...");
   foo("there were three little pigs.");
   // etc etc
}

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.