这是我的密码
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void main() {
string line;
ifstream myfile("C:\\Part1.txt");
int n = 0;
while (getline(myfile, line))
{
if (line != ""){
if (n > 8){
cout << line.substr(line.length() - (line.length()-27l)) << '\n';
}
}
n = n + 1;
}
myfile.close();
}我得到的错误是:
在网络System.Runtime.InteropServices.SEHException中出现一次“System.Runtime.InteropServices.SEHException”型异常 附加信息:外部组件引发异常。 如果存在此异常的处理程序,则可以安全地继续执行该程序。
我能做什么?
发布于 2015-02-19 10:14:34
在阅读了@Sebastian Redl,^的评论后,我认为这将解决您的问题:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
string line;
ifstream myfile;
int n = 0;
myfile.open("example.txt");
while (getline(myfile, line))
{
if (line != ""){
if (n > 8){
if (line.length() > 27)
cout << line.substr(line.length() - (line.length() - 27l)) << '\n';
}
}
n = n + 1;
}
myfile.close();
getchar();
return 0;
}https://stackoverflow.com/questions/28603519
复制相似问题