Basic "hello world" program

problem with dev c++ compiler

Page 1 of 1

6 Replies - 2633 Views - Last Post: 06 May 2008 - 12:16 PM Rate Topic: -----

#1 red_4900  Icon User is offline

  • Code T(h)inkers
  • member icon

Reputation: 21
  • View blog
  • Posts: 1,120
  • Joined: 22-February 08

Basic "hello world" program

Posted 06 May 2008 - 09:49 AM

 #include<stdio.h>
int main(){
	printf("testing greeting\n");
	getch();
	}


I'm trying to learn using the dev c++ compiler. mine is 4.9.9.2 version. and this is the error I got:

Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Program\Makefile.win"
Executing make...
mingw32-make -f "C:\Dev-Cpp\Program\Makefile.win" all
g++.exe -c test1.c -o test1.o -w -fmessage-length=0

process_begin: CreateProcess(NULL, g++.exe -c test1.c -o test1.o -w -fmessage-length=0, ...) failed.
make (e=2): The system cannot find the file specified.

mingw32-make: *** [test1.o] Error 2

Execution terminated


there is stdio.h library in the include folder, so I dont think it's the header problem. I tried compiled it using borland and it compiled and run just nicely. can anyone tell me what the heck is wrong with the compiler?

Is This A Good Question/Topic? 0
  • +

Replies To: Basic "hello world" program

#2 Guest_Whizzy*


Reputation:

Re: Basic "hello world" program

Posted 06 May 2008 - 09:52 AM

Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Program\Makefile.win"
Executing make...
mingw32-make -f "C:\Dev-Cpp\Program\Makefile.win" all
g++.exe -c test1.c -o test1.o -w -fmessage-length=0

process_begin: CreateProcess(NULL, g++.exe -c test1.c -o test1.o -w -fmessage-length=0, ...) failed.
make (e=2): The system cannot find the file specified.

mingw32-make: *** [test1.o] Error 2

Execution terminated[/i]


I have had this problem only once... I removed, and re-installed, Problem went away. May you had a file go bad...
I just compiled it, it told me getch was undelared... but that was the only error.
Was This Post Helpful? 0

#3 jeronimo0d0a  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 146
  • Joined: 03-March 08

Re: Basic "hello world" program

Posted 06 May 2008 - 10:12 AM

Getch (I believe) is in conio.h, at least on my compiler.

This post has been edited by jeronimo0d0a: 06 May 2008 - 10:13 AM

Was This Post Helpful? 0
  • +
  • -

#4 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1384
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

Re: Basic "hello world" program

Posted 06 May 2008 - 11:44 AM

It could be one of two problems - it could be a missing file, or your Dev-Cpp config is wrong. Just reinstall Dev-Cpp and it should be fine.

@Jeronimo - absolutely right, getch() is included in conio.h :)

This post has been edited by gabehabe: 06 May 2008 - 11:52 AM

Was This Post Helpful? 0
  • +
  • -

#5 Codegamer  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 127
  • Joined: 04-May 08

Re: Basic "hello world" program

Posted 06 May 2008 - 12:04 PM

Here is the right code for you:

  
//Basic Console Application in Dev-C++

#include <iostream>

using namespace std;

int main()
{
cout << "Greeetings!" << endl;

std::cout << " Press any key and enter to exit: ";  
std::cin.ignore(std::cin.rdbuf()->in_avail() + 1); 

return 0;
}


Was This Post Helpful? 0
  • +
  • -

#6 Cerolobo  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 52
  • View blog
  • Posts: 450
  • Joined: 05-April 08

Re: Basic "hello world" program

Posted 06 May 2008 - 12:11 PM

or

//Basic Console Application in Dev-C++

#include <iostream>

int main()
{
std::cout << "Greeetings!" << std::endl;

std::cout << " Press any key and enter to exit: ";
std::cin.ignore(std::cin.rdbuf()->in_avail() + 1);

return 0;
}



or the C version

#include <stdio.h>

int main(void)
{
  printf("testing greeting\n");

  printf("Hit \"Enter\" to continue\n");
  fflush(stdin); /* Remove anything that is currently in the standard input */
  getchar();     /* Wait for the user to hit the enter key */
}



What Codegamer is bascially saying, is that you shouldn't use compiler specific code, and I do agree with this.

You can learn about standard functions here

http://cplusplus.com/reference/

edit: Added C version

This post has been edited by Cerolobo: 06 May 2008 - 12:14 PM

Was This Post Helpful? 0
  • +
  • -

#7 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1384
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

Re: Basic "hello world" program

Posted 06 May 2008 - 12:16 PM

@Cerelobo and Codegamer:
The program is actually written in C, not C++ :P

Anyway, I agree with getting rid of the getch() - try taking a look at the "Holding the Execution Window Open" topic, it's pinned in this forum :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1