注册 登录
编程论坛 C++教室

请教大师!

jiaqiang1984 发布于 2008-05-24 20:07, 681 次点击
我用Microsoft Visual C++ 6.0运行下列程序

#include<iostream.h>
void main()
{char *s;
cin>>s;
cout<<s;
}

结果在输入 name  后,出现要调试;


还有我运行下列程序

#include<iostream.h>
void main()
{int s;
cin>>s;
cout<<s;
}

结果输入  a    ,得到是  0  ;
为什么啊?

是不是我电脑上的Microsoft Visual C++ 6.0有问题啊?
4 回复
#2
flyue2008-05-24 21:59
#include<iostream.h>
void main()
{
    char s[1024];
    cin>>s;
    cout<<s;
}
你试试
#3
jiaqiang19842008-05-24 22:25
我目的不是程序,我只是想知道是不是大家的Microsoft Visual C++ 6.0都是一样的结果
或者说我的Microsoft Visual C++ 6.0有没有问题
#4
bibingyan2008-05-24 22:28
因为你定义的是一个指针,没有结束标致,编译器不知道怎么结束。因些你可以试试动态分配内存,malloc  或new
#5
jiaqiang19842008-05-24 22:32
那第二个呢???
1