Results 1 to 4 of 4

Thread: How to compile a C/C++ program?

  1. #1

    Default How to compile a C/C++ program?

    Hello!
    How can i compile a C/C++ program for terminal?
    Because this doesn't work:
    Code:
     g++ hello.cpp -o hello
    This error appear:
    Code:
    error: stray \342 in program
    error: stray \200 in program
    error: stray \234 in program
    error: stray \342 in program
    error: stray \200 in program
    error: stray \235 in program
     In function int main():
    error: Hello was not declared in this scope
    error: expected `;' before World
    This is the simple programm:
    Code:
    #include<iostream>
    using namespace std;
    main()
    {
    	cout<< Hello World!;
    	return 0;
    }
    What is wrong???
    Thanks!!!

  2. #2

    Default Re: How to compile a C/C++ program?

    I have done this:All about Linux: Steps to compile C / C++ programs using GNU compiler and it worked!!!!
    Then, i think that i make a mistake somewhere!!!

  3. #3

    Default Re: How to compile a C/C++ program?

    Ok.
    The first mistake was (i think) that I have saved the file "cpp" and not "cc".
    This program is working:
    Code:
    #include <iostream>
    int
    main ()
    {
    std::cout << "Hello, world!" << std::endl;
    return 0;
    }
    The program can be compiled with the following command line:
    $ g++ -Wall hello.cc -o hello

  4. #4
    Join Date
    Sep 2008
    Location
    Bangalore, India
    Posts
    70

    Default Re: How to compile a C/C++ program?

    Seems like you have answered your own question

Posting Permissions

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