C++ 代码未到达特定行
C++ Code not reaching a particular line
我正在用 c++ 编写代码,它的编译完美,但由于某种原因它没有超出特定行。我已经检查并重新检查了所有括号。我无法弄清楚为什么会发生这种情况,因为编译器也没有给我任何错误或警告。我没有包含整个代码,如果需要更多代码,请告诉我。
int main()
{
//declaration of all the required variable used below
for(int g=0;g<e;g++)
{
//some code here
}
for(int i=0;i<e;i++)
{
//some code here
}
for(int k=1;k<v;k++)
{
//some code here
}
cout<<"n";
cout<<"reaching here
for(int k=0;k<v;k++)
{
//some code here
}
cout<<"n"; //printing a next line
cout<<"not printing this line";
return 0;
}
问题可能是您打印的行之后没有行尾。如果不是这种情况,您应该能够附加调试器(我可以解释如何回答您是否可以使用哪种环境响应此答案:Win,Lin,Mac)并确定它崩溃的位置和时间。
C++ iostreams 为可移植的下线提供"std::endl",最好不要将其与""混合使用。
使用 ideone.com 我清理了粘贴的代码来编译和清理cout语句,它似乎有效:
int main()
{
int e = 10;
int v = 12;
//declaration of all the required variable used below
for(int g=0;g<e;g++)
{
//some code here
}
for(int i=0;i<e;i++)
{
//some code here
}
for(int k=1;k<v;k++)
{
//some code here
}
cout << endl << "reaching here" << endl;
for(int k=0;k<v;k++)
{
//some code here
}
cout << endl << "not printing this line" << endl;
return 0;
}
IDE链接:http://ideone.com/e6VShc
我认为它正在打印它,但您没有看到它,因为它与您编写命令的同一行中。
相关文章:
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 代码在main()中运行,但在函数中出现错误
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 编译包含字符串的代码时遇到问题
- 我在c++代码中生成了一个运行时#3异常
- 如何在linux终端中同时编译和运行c++代码
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 在Linux for Windows上编译C++代码时出错
- 我的字符计数代码计算错误.为什么
- 孤立代码块在结构中引发异常
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 此代码是否违反一个定义规则
- 为什么我的代码在输出中增加了93天
- 我的简单if-else语句是如何无法访问的代码
- 使用动态分配的数组会导致代码分析发出虚假的C6386缓冲区溢出警告
- 为什么在这个代码结束循环中没有得到结束
- 在c代码之间共享数据的最佳方式
- 这个指针和内存代码打印是什么?我不知道是打印垃圾还是如何打印我需要的值