Author Topic: Memory crash when running program built with C::B  (Read 1671 times)

lhcoder

  • Guest
Memory crash when running program built with C::B
« on: November 22, 2006, 10:37:13 pm »
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