Menu

Could someone look at this for me and Help

Anonymous
2003-01-25
2012-09-26
  • Anonymous

    Anonymous - 2003-01-25

    Here is the problem I have to do and I need some help to understand what going on with this compiler I used MS Visual C++ and it compiled OK!!

    //Project:

    #include <iostream>
    #include <stdlib.h>
    #include <string>
    using namespace std;

    int main(int argc, char *argv[])
    {
      string name = "";
      cout << "Type your first and last name:";
      cin >> name;
      cout << endl;
      cout << name + " says, \"Hello World\"" << endl;
     
      cout <<endl;
      cout << "Press any key and <Enter> to continue ";
      cin >>name >> name;
      system("PAUSE");   
      return 0;
    }

    //Compile Log:

    Compiler: Default compiler
    Building Makefile: "C:\Dev-Cpp\Makefile.win"
    Executing  make...
    make.exe -f "C:\Dev-Cpp\Makefile.win" all
    g++.exe -c main.cpp -o main.o 

    main.cpp:1:20: iostream: No such file or directory
    main.cpp:3:18: string: No such file or directory
    main.cpp: In function `int main(int, char**)':
    main.cpp:8: `string' undeclared (first use this function)
    main.cpp:8: (Each undeclared identifier is reported only once for each function
       it appears in.)
    main.cpp:8: parse error before `=' token
    main.cpp:9: `cout' undeclared (first use this function)
    main.cpp:10: `cin' undeclared (first use this function)
    main.cpp:10: `name' undeclared (first use this function)
    main.cpp:11: `endl' undeclared (first use this function)

    make.exe: *** [main.o] Error 1

    Execution terminated

     
    • Nobody/Anonymous

      Have you told the compiler where the include is?

       
    • Nobody/Anonymous

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.