int pos=2;
if语句如下:
if(pos=0||pos>=4)
没有设定else
该判断成立,返回错误提醒,判断不成立直接运行下一语句,但是编译不会出错,但是运行的时候,报错为
double free or corruption(out)
Aborted(core dumped)
且运行结果是错的,有点没理解到是什么原因
按理来说pos为2,if中2个判断语句都是fail的,应该直接跳转到下一句才对
于是另外写了一个简单的程序
test.cpp
#include<iostream>
using namespace std;
int main(int argc,const char *argv[])
{
int pos=2;
if(pos=0||pos>=4){
cout<<"Fail"<<endl;
}
cout<<pos<<endl;
return 0;
}
用g++ -o test test.cpp编译以后,运行test
运行结果为0
变量pos的内容直接不见了,更想不通了