this is a simple example of a problem I have been having with differing programs, i am using linux ubuntu 9.10 and codeblocks 8.02 .

this is the code

#include <iostream>

using namespace std;
int main()
{
    int hiya;
    cout<<"hello world \n";
    cin.get();
    cout<<"enter a number \n";
    cin>>hiya;
    cout<<"you entered \n"<< hiya;
    cin.get();
}

it compiles but show an error message "warning GDB: Failed to set controlling terminal: operation not permitted"

then the program runs

when it gets to the last cin instead of waiting for some input it exits

When you input a number into "hiya", you will press Enter. So the last cin reads '/n' and then the program exits.(Sorry, my english is poor.)

You can also do this

#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
    int hiya;
    cout<<"hello world \n";
    getch();
    cout<<"enter a number \n";
    cin>>hiya;
    cout<<"you entered \n"<< hiya;
    getch();
}

>You can also do this: <snip conio.h crap>
You can do that...but don't teach it to others. Using conio.h is like bumping uglies with a fat chick. A lot of guys might do it, but they don't talk about it. Such is the way with bad programming practices.

Comments
n/a

>You can also do this: <snip conio.h crap>
You can do that...but don't teach it to others. Using conio.h is like bumping uglies with a fat chick. A lot of guys might do it, but they don't talk about it. Such is the way with bad programming practices.

This may very well be the best post I have ever read on Daniweb. :icon_mrgreen:

This question has already been answered. Start a new discussion instead.