Hello...

Im a newb to both C programming and DaniWeb ..

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

#include <stdio.h>
#include<Conio.h>

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

Recommended Answers

All 10 Replies

>>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.

As far as I know:

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

:)

If you write your program like this:

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

It should work..

commented: Probably not -- void main() anf getch() are wrong -4

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.

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()

Hello...

Im a newb to both C programming and DaniWeb ..

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

#include <stdio.h>
#include<Conio.h>

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.

@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".

commented: truth +14

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...

> 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.

commented: against "void main" - keeping up the tough fight +2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.