getch();

Hello everyone there, I am facing a problem in this code that when I give input to the program then I press enter and nothing is displayed. I again press enter and then my console window is disappeared without showing output.
How to solve it. here is the code:

#include <string>
#include <iostream.h>
#include <conio.h>

void main()
{
string no,number;
clrscr();

cout<<"Enter A number greater then or equal to 1,000 ";
cin>>no;
number=no.substr(0,2) + "," + no.substr(3);
cout<<number;
getch();

}
The problem is that the program is not valid C++.

-You should use <iostream> and not <iostream.h>
-You should not use <conio.h>
-You should use std::string in main, not just string
-You should use std::cout in main, not just cout
-You should use std::cin in main, not just cin
-You should not use getch()
void main() is not C++ either. int main() is.
Topic archived. No new replies allowed.