栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

C++ 读取文本内容为指定结构

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

C++ 读取文本内容为指定结构

#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;

int main()
{
	fstream f1;
	f1.open("/home/scada/source/platform/personal_test/wzh/test/dpfClassDefine.txt");
	if(!f1.is_open())//打开文件失败 
	{
		cout<< "open file failed" <
		getline(f1,line);//按行读取 
		size_t pos1 = line.find("key-value");
		size_t pos2 = line.find("Vector");
		if(pos1 != string::npos) //解析struct 
		{
			string name1 = line.substr(0,pos1);
        	string note1 = line.substr(pos1+9);
			if(t>1)
				cout << "}" << endl;
			cout << "struct " << name1 << endl;
        	cout << "//" << note1 << endl;
        	cout << "{" << endl;//输出 
		}
        else if(pos2 != string::npos)
        {
        	string name2 = line.substr(0,pos2);
        	string note2 = line.substr(pos2+15);
			if(t>1)
				cout << "}" << endl;
			cout << "struct " << name2 << endl;
        	cout << "//" << note2 << endl;
        	cout << "{" << endl;//输出 
        }
		else //解析属性 
		{
			string str1,str2,str3;
			istringstream is(line);
			is>>str1>>str2>>str3;
			cout<<"t"<
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/913621.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号