首页 > 其他分享 >字符串分割

字符串分割

时间:2022-10-02 08:22:54浏览次数:49  
标签:分割 string oldstr readfile str 字符串 include find

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
	ifstream readfile;
	readfile.open("八卦图数据源.txt");
	string str;
	string oldstr="";
    do{
    	readfile>>str;
    	if(str==oldstr){
    		break;
		}
		oldstr=str;
    	cout<<str<<"   x:"<<str.substr(0,str.find(":"))<<"   z:"<<str.substr(str.find(":")+1)<<endl;
	}while(str.size()>2&&str.find(":")>0&&str.find(":")<str.size());
	return 0; 
}

  

标签:分割,string,oldstr,readfile,str,字符串,include,find
From: https://www.cnblogs.com/As198601/p/16748218.html

相关文章