c++.command-line - Compiler Help
- Joel Leach (25/25) Apr 19 2002 Hi,
- Steve Topilnycky (18/19) Apr 19 2002 In the c++.command-line newsgroup Joel Leach wrote:
- John Hayes (5/23) Feb 26 2004 Thanks Steve! I had the exact same problem and using the pointer worked...
- Walter (6/31) Apr 19 2002 The trouble is that "string" is not defined anywhere, see where I marked...
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
In the c++.command-line newsgroup Joel Leach wrote: Here's your problem.string name; // define nameYou have to define it as char, as there is no string definition. You can do it two ways: Method 1: //Define name with a Fixed size: char name[25]; Method 2: // Define a pointer to Name: char *name; Just replace string name; with one of the methods above. They both will work. -- Regards, Steve Topilnycky Top Cat Computing Web: http://www.topcatcomputing.com:8080/
Apr 19 2002
Thanks Steve! I had the exact same problem and using the pointer worked for me...thanks again! John "Steve Topilnycky" <no.spam.steve topcatcomputing.com> wrote in message news:MPG.172a87b960b0753d989682 news.digitalmars.com...In the c++.command-line newsgroup Joel Leach wrote: Here's your problem.string name; // define nameYou have to define it as char, as there is no string definition. You can do it two ways: Method 1: //Define name with a Fixed size: char name[25]; Method 2: // Define a pointer to Name: char *name; Just replace string name; with one of the methods above. They both will work. -- Regards, Steve Topilnycky Top Cat Computing Web: http://www.topcatcomputing.com:8080/
Feb 26 2004
The trouble is that "string" is not defined anywhere, see where I marked it in the code. -Walter "Joel Leach" <spininc earthlink.net> wrote in message news:a9qbs1$22oi$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: // 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^^^^^ this is undefined. -Waltercin >> 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 greatlyappreciated!Thanks in advance, Nicky
Apr 19 2002