Note that there are some explanatory texts on larger screens.

plurals
  1. PORead in double type from txt file - C++
    primarykey
    data
    text
    <p>I'm in the midst of a university project and have decided to implement a method that can accept information from a text file (in this instance called "locations.txt"). input from the text file will look like this:</p> <pre><code>London 345 456 Madrid 234 345 Beinjing 345 456 Frankfurt 456 567 </code></pre> <p>The function looks like this currently (and you will notice I am missing the While condition to finish adding input when reaches end of text in locations.txt, i tried using eof but this didnt work?!). Also get function expects a char and so cant accept input thats a double which is what the latitude and longitude are defined as...</p> <pre><code>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-&gt;nodeCityName, MAX_LENGTH); // inputFile.get(temp-&gt;nodeLati, MAX_LENGTH); // inputFile.get(temp-&gt;nodeLongi, MAX_LENGTH); temp-&gt;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-&gt;Next != NULL) { temp2 = temp2-&gt;Next; // Move to next link in chain until reach end of list } temp2-&gt;Next = temp; } } inputFile.close(); } </code></pre> <p>Any help you can provide would be most useful. If I need to provide anymore detail I will do, I'm in a bustling canteen atm and concentrating is hard!!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload