Feb 8, 2011 at 10:34pm UTC
Using Turbo C++ 4.5, I get the following error when compiling this code:
#include <iostream.h>
#include <string.h>
int main()
{
String Name;
cout<<"Enter Name : ";
cin>> Name;
cout<<"Hello, "<<Name<<"Nice to meet you!";
return(0);
}
Unidentified symbol 'String' in function main().
Can someone please help me identify the problem? I know that's the string library because I looked for it in the compiler's folders.
Much appreciated. Thanks,
Sandman (Tyler)
Feb 8, 2011 at 10:37pm UTC
you should be including <string>
not <string.h>
, and also <iostream>
not <iostream.h>
. String name;
should be string name;
, notice the lower case s.
EDIT - you'll also either need to add using namespace std;
beneath your includes, OR instead of string name;
put std::string name;
Last edited on Feb 8, 2011 at 10:39pm UTC
Feb 8, 2011 at 10:40pm UTC
Including <iostream> and <string> causes more errors. It needs to have ".h" at the end in this case. I'll try downloading a newer compiler and rewrite the code.
I'd appreciate it if someone can edit my code and re-post it so I can see it visually :).
Thanks again.
Feb 8, 2011 at 11:04pm UTC
Got wxDev-C++. Did what you said and it compiles and runs. However it closes right away after execution. Here is my code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string Name;
cout<<"Enter your name : ";
cin>>Name;
cout<<"Hello, "<<Name;
return(0);
}
My IDE uses Delphi to compile.
Last edited on Feb 8, 2011 at 11:21pm UTC