Hello, I am looking for some help with a program i am writing. It is supposed to ask you for the name of an object and the 'create' said object. It ends with an error message saying that the hard drive was wiped. The only problem is that i can't seem to get the String to work. Any ideas? And later on i would like to have the program 'type' itself out on the page and wait a few seconds between lines if at all possible. But my main concern is the String problem.

#include <iostream>
using namespace std;
#include <iomanip>
#include <String>

int main ()
{
system("cls");

int Object;
String Object;
cout << "Enter the object you wish to create: ";
cin >> Object;
cout << "Initializing \"" << Object << "\"" << endl;
cout << "Initailization Complete" << endl;
cout << "Compiling \"" << Object << "\"" << endl;
cout << "Compiling Complete" << endl;
cout << "Creating \"" << Object << "\"" << endl;
cout << "FATAL ERROR IN C DRIVE" << endl;
cout << "ABORTING CREATION OF \"" << Object << "\"" << endl;
cout << "Program succesfully aborted" << endl;
cout << "Hard drive wiped to protect computer" << endl;
cout << "Have a nice day." << endl;

system ("pause");

}
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
system("cls");
//int Object; why are you declaring Object twice? 
string Object;
cout << "Enter the object you wish to create: ";
cin >> Object;
cout << "Initializing \" << Object << "\" << endl;
cout << "Initailization Complete" << endl;
cout << "Compiling \" << Object << "\" << endl;
cout << "Compiling Complete" << endl;
cout << "Creating \" << Object << "\" << endl;
cout << "FATAL ERROR IN C DRIVE" << endl;
cout << "ABORTING CREATION OF \" << Object << "\" << endl;
cout << "Program succesfully aborted" << endl;
cout << "Hard drive wiped to protect computer" << endl;
cout << "Have a nice day." << endl;

system ("pause");
return 0;
}

Please make sure you know how to use strings before using them.
Try that, I haven't compiled it but should work

Edited 7 Years Ago by Phil++: n/a

As for your other question about waiting between each line.. Not recommended but...

Sleep(3000);

I tried that and the output was

(10) : error C2371: 'Object' : redefinition; different basic types

(9) : see declaration of 'Object'

(12) : error C2088: '>>' : illegal for class

(13) : error C2088: '<<' : illegal for class

(15) : error C2088: '<<' : illegal for class

(17) : error C2088: '<<' : illegal for class

(19) : error C2088: '<<' : illegal for class

Can you please tell me what you are trying to accomplish with this program?
If all you are trying to do is print the string then you can use this

#include <iostream>
using namespace std;
#include <iomanip>
#include <String>

int main ()
{
system("cls");

string Object;
cout << "Enter the object you wish to create: ";
cin >> Object;
cout << "Initializing \"" << Object << "\"" << endl;
cout << "Initailization Complete" << endl;
cout << "Compiling \"" << Object << "\"" << endl;
cout << "Compiling Complete" << endl;
cout << "Creating \"" << Object << "\"" << endl;
cout << "FATAL ERROR IN C DRIVE" << endl;
cout << "ABORTING CREATION OF \"" << Object << "\"" << endl;
cout << "Program succesfully aborted" << endl;
cout << "Hard drive wiped to protect computer" << endl;
cout << "Have a nice day." << endl;

char wait; 
cin>>wait;
return 0;
}

The last part with cin>>wait stops the screen to let you read the output before the screen closes.
Disregard Phil++'s code. It won't work because he messed up the quotes.
@ Phil++
If your gonna give away free code, the least you could do is make sure it actually works.
This isn't the first time you disobeyed the rules by giving away code.

Edited 7 Years Ago by Grn Xtrm: n/a

Yes. All that i want my program to accomplish for now is to print out the string. And thank you the code worked.

My bad :) I didn't give him any free code neither did I compile it.

It is ok to make and post corrections to a poster's code. Just let him know what you did and why his original code is wrong. After all that is the point of the software development forums. Don't just throw uncompiled code at the poster. Help him to understand his mistakes.

It is ok to make and post corrections to a poster's code. Just let him know what you did and why his original code is wrong. After all that is the point of the software development forums. Don't just throw uncompiled code at the poster. Help him to understand his mistakes.

Ahh, my bad. I should have thought before editing it again with the quotation marks :P I will take the time to compile it before I submit next time (Y)

This question has already been answered. Start a new discussion instead.