|
-
April 18th, 2001, 12:43 PM
#1
Rookie Debugging
Simple unterminated constant. The problem i think is with the if statement.
int main ()
{
string name;
string address;
string phonenumber;
string name;
cout<< "What is your name? ";
cin>> name;
If name="What is your name?";
name="Amy Tay";
address="3102 Peterboro Drive";
phonennumber="330-678-7557";
cout<<"\t"<<name<<\n";
cout<<"\t"<<address<<\n";
cout<<"\t"<<phonennumber<<\n";
}
#include <iostream.h>
using namespace std;
int main()
int age, float Weight;
age=26;
weight=180;
cout<<"My age is"<<age<<"and my weight is"<<weight<<"pounds."
-
April 19th, 2001, 07:29 PM
#2
Re: Rookie Debugging
I'm a rookie as well, but one thing I saw in that code was your use of header file.
You used:
#include <iostream.h
using namespace std;
I know that gives me an error when I build it.
If you are going to code:
using namespace std;
Then you want to code:
#include <iostream>
rather than:
#include <iostream.h
It doesn't compile with the error you mentioned, but will give a different error, so I'm not sure if that will help you or not.
BTW, I use vc++ so if you are using a different compiler, then it may not cause an error... not sure.
p.s. I would recommend using:
#include <iostream>
using namespace std;
over the .h method because .h was deprecated about 5 years ago.
Hope it helped a bit.
-
April 22nd, 2001, 09:02 PM
#3
Re: Rookie Debugging
cout<<"\t"<<name<<\n";
cout<<"\t"<<address<<\n";
cout<<"\t"<<phonennumber<<\n";
must be ... <<"\n" or better << std::endl;
i also recommend using <iostream> instead of <iostream.h>, and 'using namespace std;', as the other poster suggested.
Chris
----
http://www.crupp.de
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|