0

I've just started learning C++ on Linux. I have written a very small program which compiles but I get run time errors everytime I run it. The code is shown below:

#include<iostream>

int DoubleOf(int n);

int main() {
    std::cout << "Double of 5 is " << DoubleOf(5);
    return 0;
}

int DoubleOf(int n) {
    return n+n;
}

I compile it using g++ main.cpp -o main.out, without any errors but when I run it, sh main.out, it outputs:
main.out: 3: main.out: Syntax error: Unterminated quoted string

Any help is appreciated.

3
Contributors
2
Replies
19
Views
2 Years
Discussion Span
Last Post by sepp2k
1

gcc produces a binary executable, not a shell script. To run it, type ./main.out.

Votes + Comments
Really stupid of me... thank you so much
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.