www.digitalmars.com         C & C++   DMDScript  

c++.chat - Help!

reply "Nicky" <spininc earthlink.net> writes:
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
Apr 19 2002
parent reply "Pavel Minayev" <evilone omen.ru> writes:
"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.
Apr 20 2002
parent reply beeran telia.com writes:
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
Aug 11 2002
parent Jan Knepper <jan smartsoft.cc> writes:
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 !!
Aug 11 2002