【发布时间】:2014-04-16 15:13:20
【问题描述】:
我正在寻找有关在我的 C 文件中记录退出代码的说明。
例如,我有以下内容:
if( !(new_std = (student*) malloc(sizeof(student))) )
exit(1);
//+1 is for the \0, strlen does not give us that one!
if( !(new_std->name=(char*) malloc(1+sizeof(char)*strlen(name)))){
free(new_std);
exit(1);
}
在我的文件中记录的正确方法是什么,以数字 1 退出,意味着 内存分配失败?
【问题讨论】: