首页 > 其他 > 详细

读取一行

时间:2016-02-26 20:22:54      阅读:226      评论:0      收藏:0      [点我收藏+]


#include<map>
#include<iostream>
#include<fstream>
#include<string>
using namespace std;

string src="/usr/local/www.tendebug.com/doc/mysql.xml";

int read_mysql_xml(string &host,string &user,string &pass, string &dbname,int &port)
{
ifstream readfile;
string line;
int count=5;
map<string ,string> infile;

readfile.open(src.c_str(),ios::in);

if(!readfile)
{
return 1; /*没有打开该文件*/
}
while(count--)
{
getline(readfile,line);
string::size_type index = line.find_first_of(" ",0);
string first = line.substr(0,index);
string second = line.substr(index+1);
infile[first]=second;
}
host = infile["host"];
user = infile["user"];
pass = infile["pass"];
dbname = infile["dbname"];
port = atoi(infile["port"].c_str());
}

读取一行

原文:http://www.cnblogs.com/chensheng-zhou/p/5221528.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!