please...can you help me

Hi guys,I am so happy to find a such Great website about c++, and i hope from all of you to help my to find a solution to my assignment.

>>the assignment is:
write a program in c++ that can delete each letter in five second for each letter from your name.

Note: I am so novice in the C + + .
so please guys help my, god bless you all. :)
Last edited on
1 letter per second?

Hmm...Well, this... Give me a second.

This would be easier if you were running Windows and I would let you run the Sleep() function.
my running is Windows .
Which IDE are you using?

Code::Blocks?
Visual Studio (Express) 2010?
am using Dev-c++ IDE.

And i don't know about
Code::Blocks?
Visual Studio (Express) 2010?
You can do this with any compiler and any IDE. Just use the standard time() function in a loop to implement the delay.

To Ben: I know there are better ways but for someone who learns the language I doubt there is any point in using platform dependent sleep functions. Also if this is an assignment and the teacher hasn't mentioned the Sleep function I doubt they expect them to use it.
Last edited on
Since it's a rather simple program, I've written it for you to study.
For simplicity, I just used Sleep() to wait for 5 sec AFTER erasing each character.
For better accuracy, you might need to look into those functions under <time.h>.
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 <iostream>
#include <Windows.h>
using namespace std;

const int SEC = 5;

void main()
{
	char name[256];

	cout << "What's your name?" << endl;
	cin.getline(name, 256);
	cout << "Erasing your name..." << endl;

	for (char* tmp = name; *tmp != '\0'; tmp++)
	{
		cout << tmp << endl;
		Sleep(SEC*1000);
	}

	cout << "Done!" << endl;

	system("pause");
}
Thank you all for the help . the code is working But Can You make it start the erasing from the end of the name?
for example if i write John it will start erasing from n to j.
Last edited on
Topic archived. No new replies allowed.