그래서 입력 파일의 모든 행에서 특정 부분을 가져 오려고합니다. 지금까지이 있어요 : 나는 (line.substr(line.find("VAR_CAL_PATH2=") + 1))
부분은 "경로 1 ="후 그리고 경로 1에 넣어 것입니다 무엇이든 취할 것 이해 것에서입력 파일에서 변수 추출 및 설정 C++
ifstream fin("text.txt");
string line;
while (getline(fin, line)) {
if (line.find("Set") == 0)
{
istringstream sin1(line.substr(line.find("path1=") + 1));
sin1 >> path1;
istringstream sin2(line.substr(line.find("path2=") + 1));
sin2 >> path2;
}
}
을, 나는 그것을 잘못있어 같아요. 내 입력 파일은 두 줄이 있습니다
Set path1="somepath"
Set path2="someotherpath"
while 루프 내가 얻을 종료
경로 1 을 = "설정"및 경로 2 = "someotherpath"하지만 내가 원하는 경로 1 = "somepath는"및 경로 2 = "someotherpath"입니다
당신은 모든 라인의 경로 1과 경로 2 모두를 업데이트 문제를 일으킨다. –