954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

TurboC3 not compiling basic programs help....

Hello...

Im a newb to both C programming and DaniWeb ..

the prob is tht i try to compile this program in TurboC3

#include
#include

main()
{
printf( "hello" );
getch();
}

when i press " alt+F9 " it says " Warning:: program should return a value" and no errors

When i press " Alt + F5 " I see nothing but a black screen and cursor on it (like in logo) when i have to get Hello....

wht can be the problem...

anything wrong in the program?

plz help me...

regards
yesh

yeshkadiyala
Newbie Poster
2 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

>>anything wrong in the program?

1. its int main().

2. Add return 0; as the last line in main()

3. Add '\n' to the end of Hello, making it "Hello\n"

4. You might need to add fflush(stdout) after that print statement.

If the above doesn't fix the problem then I don't know what's wrong.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

As far as I know:

Alt + f9 -> just complile
use:
Ctrl + f9 -> compile + run

:)

Luckychap
Posting Pro in Training
444 posts since Aug 2006
Reputation Points: 83
Solved Threads: 61
 

If you write your program like this:

#include <stdio.h>
#include <conio.h>
void main(){
printf("\nHello World !!");
getch();
}

It should work..

deepugtm
Junior Poster in Training
96 posts since Aug 2008
Reputation Points: 2
Solved Threads: 2
 

I am too new to c programming.I think as the program doesnt return any value you should either put void main,or give return 0 at the end of program.
Just take it as a suggestion not sure if it is tha solution.

alvalany
Junior Poster in Training
61 posts since Jul 2009
Reputation Points: 8
Solved Threads: 2
 
I am too new to c programming.I think as the program doesnt return any value you should either put void main,


NEVER use void main()

WaltP
Posting Sage w/ dash of thyme
Moderator
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
 

Hello...

Im a newb to both C programming and DaniWeb ..

the prob is tht i try to compile this program in TurboC3

#include #include

main() { printf( "hello" ); getch(); }

when i press " alt+F9 " it says " Warning:: program should return a value" and no errors

When i press " Alt + F5 " I see nothing but a black screen and cursor on it (like in logo) when i have to get Hello....

wht can be the problem...

anything wrong in the program?

plz help me...

regards yesh


1.CTRL+F9: to see the output
2. main should return int and nothing else
3. C is case sensitive, so Conio.h is wrong.
4. If I'm not wrong, ALT+F5 is used to hold the screen if you're not using getch().
5. Use code-tags to post your code.

9868
Light Poster
36 posts since Mar 2009
Reputation Points: 45
Solved Threads: 7
 

@OP
I apologise if this remark seems a little out of place with respect to your query, but I would suggest that you look at using an up-to-date setup. Turbo C is pretty dated.

Personally, for the Windows platform, I would recommend the MinGW toolchain in conjunction with your favourite editor or IDE. Codeblocks is a good IDE option and you can download it with MinGW as part of the package.

I use MinGW in conjunction with the CDT tooling in Eclipse. It works well - except that there are still some integration issues with the gdb debugger - but it's not a "show-stopper".

yellowSnow
Posting Whiz in Training
203 posts since Jul 2009
Reputation Points: 651
Solved Threads: 35
 

I should have posted this in my previous blurb. Here's a link to a sticky post at the head of the C forums page:

http://www.daniweb.com/forums/thread50370.html

yellowSnow
Posting Whiz in Training
203 posts since Jul 2009
Reputation Points: 651
Solved Threads: 35
 

u guys are gr8 ... thnx

by the way it worked for me... when I pressed ctrl + f9 & then alt+f5

and no matter wht I used ..
main() or void main() or int main() it worked for me

and return 0; solved the warning problem

thank u guys once again...

yeshkadiyala
Newbie Poster
2 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

> main() or void main() or int main() it worked for me
Understand that there is a difference between the language and a compiler.

The language states that main returns int.

Your compiler (just one of many) is an implementation of that language. All compilers extend the language in some way, for a number of reasons.

Learn the language, and not the compiler.
Or at least learn that there is a difference, so that it is not a total surprise to you when you come to use another compiler.

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You