.txt文件内容按行读取
char buf[1024]; std::string ConfigFile = “GadgetronConfig.txt”; FILE* fp = fopen(ConfigFile.c_str(), “r”); while (fgets(buf, sizeof(buf), fp)) { printf(“%s/n”, buf);
std::string str = buf;
string::size_type idx;
std::string subString;
subString = "address=";
idx = str.find(subString);
if (idx != string::npos)
{
int len = subString.length();
g_strIP = str.substr(len, str.length() - len - 1);
}
.txt文件内容按行读取最先出现在Python成神之路。
共有 0 条评论