| Thread overview | ||||||
|---|---|---|---|---|---|---|
|
April 20, 2002 Help! | ||||
|---|---|---|---|---|
| ||||
Hi,
I tried to compile the program shown below, but got the following error
message:
String name: define name
^
1.1.cpp(10) : Error: undefined identifier 'string'
--- errorlevel 1
Code:
// ask for a person's name, and greet the person
#include <iostream.h>
#include <string.h>
int main(void)
{
// ask for the person's name
cout << "Please enter your first name: ";
// read the name
string name; // define name
cin >> name; // read into name
// write a greating
cout << "Hello, " << name << "!" << endl;
return 0;
}
If anyone knows why I'm getting this error, it would be greatly appreciated!
Thanks in advance,
Nicky
| ||||
April 20, 2002 Re: Help! | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Nicky | "Nicky" <spininc@earthlink.net> wrote in message news:a9qgeb$2c38$1@digitaldaemon.com... > Hi, > I tried to compile the program shown below, but got the following error > message: > > String name: define name > ^ > > 1.1.cpp(10) : Error: undefined identifier 'string' > --- errorlevel 1 > > Code: > > #include <iostream.h> > #include <string.h> Here's the problem: <string.h> doesn't define class string. It is declared in <string>, and don't forget about namespacing: #include <iostream.h> #include <string> using namespace std; That should do it. | |||
August 11, 2002 Re: Help! | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | Im having the same problems as this guy did and when i try this solution all i get is "Fatal error: unable to open input file 'stl_config.h' --- errorlevel 1" here is my code! ----------------------------------- #include <..\include\iostream.h> #include <..\stl\string> using namespace std; void main(){ cout << "hello\n"; } ----------------------------------- if i remove the "include string" it works but is of no use to me !! In article <a9sagm$1adi$1@digitaldaemon.com>, Pavel Minayev says... > >"Nicky" <spininc@earthlink.net> wrote in message news:a9qgeb$2c38$1@digitaldaemon.com... > >> Hi, >> I tried to compile the program shown below, but got the following error >> message: >> >> String name: define name >> ^ >> >> 1.1.cpp(10) : Error: undefined identifier 'string' >> --- errorlevel 1 >> >> Code: >> >> #include <iostream.h> >> #include <string.h> > >Here's the problem: <string.h> doesn't define class string. It is declared in <string>, and don't forget about namespacing: > > #include <iostream.h> > #include <string> > using namespace std; > >That should do it. > > > Bjorn | |||
August 11, 2002 Re: Help! | ||||
|---|---|---|---|---|
| ||||
Posted in reply to beeran | beeran@telia.com wrote: > Im having the same problems as this guy did and when i try this solution all i get is "Fatal error: unable to open input file 'stl_config.h' Where is your stl_config.h? You might what to try: sc -I\include -I\stl Jan > > --- errorlevel 1" > > here is my code! > ----------------------------------- > #include <..\include\iostream.h> > #include <..\stl\string> > using namespace std; > void main(){ > cout << "hello\n"; > } > ----------------------------------- > if i remove the "include string" it works but is of no use to me !! | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply