Thread overview
Help!
Apr 20, 2002
Nicky
Apr 20, 2002
Pavel Minayev
Aug 11, 2002
beeran
Aug 11, 2002
Jan Knepper
April 20, 2002
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
"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
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
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 !!