-3

I was trying my first c program in eclipse. Now after installing the c/c++ plugin i have c/c++ perspective.

But when I tried to run this simple C code, a window pops up titled "Application

Launcher", and it contains the following message: "Launch failed.Binary not found".

Please let me know if the mistake in the c code I wrote or in any something else.

C code:

#include <iostream.h>

main() {
    cout<<"Hello world!\n";
}
MOHAMED
  • 41,599
  • 58
  • 163
  • 268
Amr Bakri
  • 273
  • 3
  • 11

3 Answers3

0

the code you put is C++ code and not C code.

with Eclipse you have first to create new project:

File --> New --> C++ Project --> Executable --> Emptyproject

Give a name to your project and then continue the setting till finish the creation of the project

Edit your C++ source code and then build your project with

Project --> Build All

And then run your binary with the famous green button. or with:

Run --> Run

MOHAMED
  • 41,599
  • 58
  • 163
  • 268
0

Correct C++ code is

#include <iostream>

int main() {
    std::cout<<"Hello world!\n";
}

Note it's <iostream> not <iostream.h>, std::cout not cout, and int main not main. These mistakes seem to indicate you are learning C++ from a very out of date source.

john
  • 7,897
  • 29
  • 27
0

That's not C; it's an ancient dialect of C++, which a modern compiler will probably reject even if you don't try to build it as C.

A "hello world" in C might look like:

#include <stdio.h>

int main() {
    printf("Hello world!\n");
}

and in this century's dialects of C++:

#include <iostream>

int main() {
    std::cout << "Hello world!\n";
}

Now you should decide whether to learn C or C++ (which are very different languages), and find a good book on the subject. For C++, start here.

Community
  • 1
  • 1
Mike Seymour
  • 249,747
  • 28
  • 448
  • 644