Note that there are some explanatory texts on larger screens.

plurals
  1. POistringstream not storing anything in variables
    primarykey
    data
    text
    <p>I'm having an issue with istringstream not storing the values it reads. Here is what I have:</p> <pre><code> if(inputFile.good()){ //Make sure file is open before trying to work with it //Begin Working with information cout &lt;&lt; "\tIn File: " &lt;&lt; input &lt;&lt; endl; cout &lt;&lt; "------------------------------------" &lt;&lt; endl; int number_of_lines = 0; std::string line; while (std::getline(inputFile, line)){ ++number_of_lines; } Time times[number_of_lines]; double math[number_of_lines]; std::string input; int hh, mm; for(int loop=0;loop&lt;number_of_lines;loop++){ std::getline(inputFile, input); std::istringstream(input) &gt;&gt; mm &gt;&gt; hh &gt;&gt; math[loop]; cout &lt;&lt; "hours = " &lt;&lt; hh &lt;&lt; endl; times[loop].setTimeHours(hh); times[loop].setTimeMinutes(mm); times[loop].show(); cout &lt;&lt; "*" &lt;&lt; math[loop] &lt;&lt; endl; } std::cout &lt;&lt; "Number of lines in text file: " &lt;&lt; number_of_lines &lt;&lt; "\n" &lt;&lt; endl; }else{ cout &lt;&lt; "Could not open file!!!" &lt;&lt; endl; } </code></pre> <p>The file I'm reading looks like this:</p> <pre><code>90 1 3.0 1 1 100.0 2 34 5.1 </code></pre> <p>And the output when I run:</p> <pre><code> In File: data04.txt ------------------------------------ hours = 0 Operation To Be Done = 0:2336552*1.15384e-317 hours = 0 Operation To Be Done = 0:2336552*1.58101e-322 hours = 0 Operation To Be Done = 0:2336552*1.15397e-317 Number of lines in text file: 3 </code></pre> <p>Anyone know why its not storing the values?</p>
    singulars
    1. This table or related slice is empty.
    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