#include <iostream>
#include <conio>
void main ()
{    

     cout<<"rose mary";
     getch();

}    

Good for you. Well done.

Here are some problems with it:

Line 2 - conio is a non-standard header and using it comes with risks. Modern typical PC systems do NOT come with anything named conio, so by using it you're already restricting yourself. Don't use it.

Line 3 - void main() is wrong. Just plain wrong. It is NOT C++. It never has been. Your compiler should NOT let you do this. If it does, you should throw away your compiler and get one that only lets you code in C++, and not some crazy language that looks like C++. In C++, main returns an int, always always always. int main()

Line 7 - This is a function from the conio header. I suspect you're doing it because you want the program not to finish until you press a key. There are ways to do this without using a non-standard library.

thank u so much ..
so what should i use instead of <conio> ??
my compiler doesnt show me void main() in error msg ..
and if i write int main() then
should i write at the end of program return 0;?? ..about line 7 ..i write getch(); to make the program window installing or showing after i finish the program writing ..so what should i write here to finish the program without doing these step returning to that the <conio> is non-standard ..and can u write an example program for me please ..

so what should i use instead of <conio> ??

I think nothing.Because in your code you use conio for just getch() function.I never realized the need of using conio and i think will never realize because i use standardize c++.And there is no need to use getch() for finishing a prgram by pressing any key.Its automatic (i don't know why ?).You can use code::block IDE which comes with GCC.

i think you are probably working with old aged compiler(like turbo)

my compiler doesnt show me void main() in error msg ..

But it should at least give a warning message.check it.

i write int main() then
should i write at the end of program return 0;?? .

yes, it will expect to return an integer value and this case and return 0 means your program executed without errors.

nd can u write an example program for me please ..

Sure ,here is the sample code :-

#include<iostream>
using namespace std;
int main()
{
cout<<"i'm back to daniweb.";
return 0;
}

hope this helps you.

commented: Nice! +15

i wrote this simple code but there is an error msg tells me "namespace name expected" what is that mean ?? ..
i write

#include<iostream>
using namespace std;
int main()
{
cout<<"magico";
return 0;
}

so whats the wrong with this one ??

What compiler are you using? Is it from before about 1998? C++ has moved on in the last twenty years.

oh not old like that am using borland 5.02 i know it is old but not too old ..so what do u advise me to use ??? for C++

Actually Borland C++ 5.02 was released in 1997. Not quite 20 years but pretty darn close. Code::Blocks with the GCC compiler is a pretty good choice, and has the advantage of being cross-platform. This means that you can copy your files over to your new computer if you decide to change your operating system.

thaaanks soo much for these important information ..i installed code::blocks .. really am shocked because in my faculty they teaching us how to brogram with C++ on borland 5.02 !!! i cant get how !!!

Glad you were able to do that. Just remember that now you'll have to un-learn some bad habits, but atleast you'll be on a better path.

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.