저는 대학 프로젝트 중간에 있으며 텍스트 파일 (이 경우에는 "locations.txt")에서 정보를 받아 들일 수있는 방법을 구현하기로 결정했습니다. 텍스트 파일에서 입력이 다음과 같이 표시됩니다txt 파일에서 double 유형으로 읽기 - C++
London
345
456
Madrid
234
345
Beinjing
345
456
Frankfurt
456
567
을 기능은 현재 다음과 같습니다 (그리고 당신은 내가 locations.txt 텍스트의 끝에 도달하면 입력 추가를 완료하는 동안 조건을 잃었 알, 나는 시도 eof 그러나이 didnt 한 직업을 사용한다?!). 또한 함수는 문자를 기대 얻을 그래서 캔트 입력을 허용 ... 위도와 경도로 정의 무엇 인
void populateList(){
ifstream inputFile;
inputFile.open ("locations.txt");
temp = new locationNode; // declare the space for a pointer item and assign a temporary pointer to it
while(HASNT REACHED END OF TEXT FILE!!)
{
inputFile.getline(temp->nodeCityName, MAX_LENGTH);
// inputFile.get(temp->nodeLati, MAX_LENGTH);
// inputFile.get(temp->nodeLongi, MAX_LENGTH);
temp->Next = NULL; //set to NULL as when one is added it is currently the last in the list and so can not point to the next
if(start_ptr == NULL){ // if list is currently empty, start_ptr will point to this node
start_ptr = temp;
}
else {
temp2 = start_ptr;
// We know this is not NULL - list not empty!
while (temp2->Next != NULL)
{
temp2 = temp2->Next; // Move to next link in chain until reach end of list
}
temp2->Next = temp;
}
}
inputFile.close();
}
당신은 가장 유용한 제공 할 수있는 어떤 도움을 더블 이잖아. 내가 더 이상 자세하게 설명 할 필요가 있다면, 나는 떠들썩한 식당에 있고 집중하기가 어렵다 !!
들여 쓰기를 통해 완전히 편집해야합니다. 코드를 이해하기가 어렵습니다. – unwind