List244
asked on
Order Correction
#include <iostream.h>
#include <conio.h>
void CPost();
int main()
{
CPost();
getch();
return 0;
}
void CPost()
{
cout<< "Hello\n";
}
I have the following code. I have put CPost to its
own function in attempt to answer my own
question, it did not work, but I post it this way
anyway. My question is how do I force it to
Cout then GetCH. Currently it does GetCH then
Cout, which ... messes things up, and prevents
me from continuing on.
#include <conio.h>
void CPost();
int main()
{
CPost();
getch();
return 0;
}
void CPost()
{
cout<< "Hello\n";
}
I have the following code. I have put CPost to its
own function in attempt to answer my own
question, it did not work, but I post it this way
anyway. My question is how do I force it to
Cout then GetCH. Currently it does GetCH then
Cout, which ... messes things up, and prevents
me from continuing on.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It works as:
This deals with the namespace problem pointed out by jaimie for the cout and changes your getch to getChar() from the C standard library
#include <iostream>
#include <stdio.h>
void CPost();
int main()
{
CPost();
getchar();
return 0;
}
void CPost()
{
std::cout<< "Hello\n";
}
This deals with the namespace problem pointed out by jaimie for the cout and changes your getch to getChar() from the C standard library
#include <iostream>
#include <stdio.h>
void CPost();
int main()
{
CPost();
getchar();
return 0;
}
void CPost()
{
std::cout<< "Hello\n";
}
sorry getchar() not getChar()
ASKER
I know I can use Cin but, I wanted to avoid that.
However, adding the namespace worked out
great, thanks jaime.
However, adding the namespace worked out
great, thanks jaime.
twobitadder,
> #include <iostream>
> #include <stdio.h>
With <iostream> you should really use:
#include <cstdio>
> #include <iostream>
> #include <stdio.h>
With <iostream> you should really use:
#include <cstdio>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
cout & cin are tied together, so that things will work in order.
If you mix c-library methods with c++ streams, there there is guarantee on the order.
Ciao
SirHando