c ++阅读问题\ 0

时间:2017-06-07 08:49:20

标签: c++ ifstream

早上好,

我在c ++中编写了一个小程序,它读取了一些csvtxt文件,然后将它们与一些规则进行比较。

我的问题是每个字母后导出都有一些'\0',我无法更改导出。

所以我正在尝试阅读文件并删除'\0'

目前我正在使用以下代码执行此操作:

#include <iostream>
#include <string>
#include <vector>
#include <fstream>
int main()
{
    ifstream QuelleExport;
    string temp;
    int found;
    vector<InstitutionsDaten> vecInstitutionsDaten;

    //Reading the Path out of a Text File and storing it into 'QuelleExport'
    found = temp.find("PfadExport=");
    if (found > 0)
    {
        cout << "Der Export wird aus folgender Datei ausgelesen: " << endl;
        QuelleExport = Allgemein::lesenöffnen(temp.replace(0, temp.find_first_of("= ") + 2, ""));
     }
     while (getline(QuelleInstitutionsDaten, temp))
     {
         try 
         {
             if (temp != "")
             {
                 remove(temp.begin(), temp.end(), '\0');
                 InstitutionsDaten tempClass(temp);

                 vecInstitutionsDaten.push_back(tempClass);
                 temp.clear();
             }
         }
         catch (...)
         {

         }
     }
}

替换工作经常但不是每次都有效,而且像字符串temp这样的接缝有时会有不应该存在的数据。

是否有可能删除所有c_str转义字符而不删除它们,或者您是否有其他解决方案?

0 个答案:

没有答案