How to print a letter of string second by second

Sorry for unclear topic. The thing what i'm trying to do is, i have a sentence and i want to print it but after 1st letter, the 2nd letter must wait for a 1 second. and after the printing 2nd letter program should display it after waiting another second. actually i would add this to the start of another self-study project(bank system)

i have tryed couple of times and none of them didn't worked. here is what i have lately:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <cstdlib>
#include <iostream>
using namespace std;

int main(void)
{
    char sentence[45]="TimurBank Customer Account Management System";

    int i; // timer counter
    int idx=(-1); // letter position
    int modres; // modulus operation result

    modres = i%5000;

    // i assume looping from 0 to 5000 as 1 second as time, but i may be wrong
    for (i=0; i<=225000; i++){ // 225000 = 45*5000
        while (modres == 0){
            idx=idx+1;
            cout<<sentence[idx];
        }
    }

    return (0);
}


i will be appriciate to all kind of suggestions and helps.

Regards,
Timur

*ps: i don't know if it makes any difference, but i use netbeans on ubuntu. just for info
Last edited on
In windows there is Sleep() API, don't know the *nix equivalent to that.
Ok, i will search that API's equivalent.

But, if there is any way to solve it in algorithmic way, i would prefer to do it in that way. can you help me about it?
In linux the API is called sleep().
1
2
3
4
5
6
7
8
9
10
sleep - Sleep for the specified number of seconds 
Synopsis
#include <unistd.h>
unsigned int sleep(unsigned int seconds);
Description
sleep() makes the current process sleep until seconds seconds have elapsed or a signal arrives which is not ignored. 
Return Value
 Zero if the requested time has elapsed, or the number of seconds left to sleep. 
Conforming to
 POSIX.1-2001.


This is taken from Google.
thank you very much modoran
Topic archived. No new replies allowed.