Find the answer to your Linux question:
Results 1 to 5 of 5
hello everyone ive just brought a new computer for uni its a aspire one im trying to build programs this is my code #include <iostream> using namespace std; int main ...
  1. #1
    Just Joined!
    Join Date
    Aug 2008
    Posts
    3

    compiling problems

    hello everyone ive just brought a new computer for uni its a aspire one
    im trying to build programs
    this is my code
    #include <iostream>

    using namespace std;
    int main (void)
    {
    cout <<"hello world";
    return 0;
    }

    this is my error

    [user@localhost UNI]$ g++ -I/usr/include/c++ -o world world.c
    world.c:1: error: stray ‘\357’ in program
    world.c:1: error: stray ‘\274’ in program
    world.c:1: error: stray ‘\203’ in program
    world.c:1: error: expected constructor, destructor, or type conversion before ‘<’ token
    world.c: In function ‘int main()’:
    world.c:7: error: ‘cout’ was not declared in this scope

    i cant figure out what is wrong

    can anyone help please
    thanks

  2. #2
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    your pound symbol #include <iostream>

    is not a pound

    this is a pound ## notice the difference

    so just change #include <iostream> to #include <iostream>

    and re-compile

    hope this helps

  3. #3
    Just Joined!
    Join Date
    Aug 2008
    Posts
    3
    i tryed that and i still got the error
    world.c:1:20: error: iostream: No such file or directory

    any ideas??

  4. #4
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    I copied your code and compiled it with g++ -o world world.c and had no problems with it, that is after I change your pound sign to #.

    why are you compiling with -I/usr/include/c++

    g++ -I/usr/include/c++ -o world world.c

  5. #5
    Just Joined!
    Join Date
    Aug 2008
    Posts
    3
    i tryed that and it worked
    thank you soo much i can now write programs in uni now :P
    thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...