方舟焦土代码怎么用:在运行C++时,内存错误的问题;

来源:百度文库 编辑:中科新闻网 时间:2024/05/01 23:12:27
跪求高手作答:
在运行C++编写的程序的时候,为什么一个我看着一点错误都没有的程序,用Visual c++.6.0 运行的时候
会弹出一个对话框:内容是:跪求高手作答:::
"0x004156de"指令引用的"0xcccccccc"内存.该内存不能为"往日written".
要中止程序,请单击"确定".
要调试程序,请单击"取消".
我写的代码如下,很是简单的一段:
#include"iostream"
struct month
{
int numbers;
char name[4];
};
#include"string.h"
void main()
{
char *m;
struct month months[12]={{31,"jan"},{28,"feb"},{31,"mar"},{30,"api"},{31,"may"},{30,"jun"},
{31,"jul"},{31,"aug"},{30,"sep"},{31,"oct"},{30,"nov"},{31,"dec"}};
cout<<"Input Data:";
cin>>m;
for(int i(0);i<12;i++)
{
if(strcmp(months[i].name,m)==0)
cout<<months[i].numbers<<','<<endl;
break;
}

}
你说的很含糊,能不能帮忙改一下啊,
感激不尽~~!!
我是处学C++的,
就当做帮帮晚生了

很简单

我汗,你调用istream& operator>>(istream&, char*)
函数前是不是该想想它使起什么作用的?!
Line:(cin>>m;)
输入字符串能这么调用么?m的初值未改,当然就有可能调用不可调用的内存了。