News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Memory crash when running program built with C::B

Started by lhcoder, November 22, 2006, 10:37:13 PM

Previous topic - Next topic

lhcoder

Hi,

When I run some of my code built with C::B, I get an error from Windows (<program name> has encountered a problem and needs to close... etc).  If I take out a certain line, it works fine.  Here is a small program that will cause it.

#include <iostream>
#include <string>

using namespace std;

int main()
{
    string fname;
    string lname;

    cout << "what is your first name? ";
    cin >> fname;
    cout << "what is your last name? ";
    cin >> lname;

    cout << "your name is " << lname << ", " << fname << endl;  <---- offending line

    return 0;

}

C::B configurations:
Compiler: borland C++ 5.5
Linker tab:<borland dir>\lib\cw32mt.lib
               <borland dir>\lib\PSDK\user32.lib
               <borland dir>\lib\PSDK\kernal32.lib

everything else is default.  If you have any ideas, I'd appreciate your help.

Thanks