首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在网络System.Runtime.InteropServices.SEHException中出现一次“System.Runtime.InteropServices.SEHException”型异常

在网络System.Runtime.InteropServices.SEHException中出现一次“System.Runtime.InteropServices.SEHException”型异常
EN

Stack Overflow用户
提问于 2015-02-19 10:06:43
回答 1查看 1.2K关注 0票数 0

这是我的密码

代码语言:javascript
复制
#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”型异常 附加信息:外部组件引发异常。 如果存在此异常的处理程序,则可以安全地继续执行该程序。

我能做什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-02-19 10:14:34

在阅读了@Sebastian Redl,^的评论后,我认为这将解决您的问题:

代码语言:javascript
复制
#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;
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28603519

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档