C程序中编译时错误和运行时错误之间的区别
错误或异常是指代码执行中断,因此最终用户无法获得预期的结果。基于事件的产生或识别,我们可以将其归类为编译时错误和运行时错误。
以下是编译时错误和运行时错误之间的重要区别。
编译时错误与运行时错误示例
编译演示
#include<stdio.h>
public class CompileDemo{
void main(){
int x = 100;
int y = 155;
//缺少分号
printf("%d", (x, y))
}
}输出结果
error: expected ';' before '}' token
示例
运行时演示文件
include<stdio.h>
public class RuntimeDemo{
void main(){
int n = 9;
div = 0;
div = n/0;
printf("resut = %d", div);
}
}输出结果
warning: division by zero [-Wdiv-by-zero] div = n/0;
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短