#include <conio.h>
#include <iostream.h>
void main()
{
char str[100];
cout<<"please enter your name:";
cin>>str;
cout<<"hi,This is a message In VC6.0 envinoment!\n";
cout<<"press any key to exit";
getch();}以上这段代码在BC下运行正常,不知为何在VC6.0下后二条显示信息看不到,第一条显示信息可以看到,不知何故?

解决方案 »

  1.   

    改为:
    #include <conio.h>
    #include <iostream.h>
    void main()
    {
    char str[100];
    cout<<"please enter your name:";
    cin>>str;
    cout<<"hi,This is a message In VC6.0 envinoment!\n"<<endl;
    cout<<"press any key to exit"<<endl;
    getch();

    }
      

  2.   

    VC对回车的处理不一样,\n它不会输出,还在BUFF中
    这样就可以(也是标准的c++写法)
    #include <conio.h>
    #include <iostream.h>
    void main()
    {
    char str[100];
    cout<<"please enter your name:";
    cin>>str;
    cout<<"hi,This is a message In VC6.0 envinoment!"<<endl;
    cout<<"press any key to exit";getch();}