Note that there are some explanatory texts on larger screens.

plurals
  1. PO"Exploring C++ book" compiler setup
    text
    copied!<p>I just got this book "Exploring C++" and I'm on my first lesson. I've been doing C# for a couple years as a hobby so i though why not give C++ a try.</p> <p>In the book it says i need to setup my compiler to use standard C++. I am using visual studio 2010 so i did. <a href="http://msdn.microsoft.com/en-us/library/ms235629.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms235629.aspx</a></p> <p>but when i go to compile the code it all works fine except for one if statement.</p> <p>i have triple checked just as instructed so it must be something with the tools. </p> <p>specifically </p> <pre><code>if (not in) // this line here { std::perror(argv[1]); return EXIT_FAILURE; } </code></pre> <p>The full sample</p> <pre><code>#include &lt;algorithm&gt; #include &lt;fstream&gt; #include &lt;iostream&gt; #include &lt;iterator&gt; #include &lt;ostream&gt; #include &lt;string&gt; #include &lt;vector&gt; void read(std::istream&amp; in, std::vector&lt;std::string&gt;&amp; text) { std::string line; while (std::getline(in, line)) text.push_back(line); } int main(int argc, char* argv[]) { std::vector&lt;std::string&gt; text; if (argc &lt;2) read(std::cin, text); else { std::ifstream in(argv[1]); if (not in) { std::perror(argv[1]); return EXIT_FAILURE; } read(in,text); } std::sort(text.begin(), text.end()); std::copy(text.begin(), text.end(), std::ostream_iterator&lt;std::string&gt;(std::cout, "\n")); } </code></pre> <p>I would really like to continue with this book so any help is greatly appreciated.</p> <p>And I apologize if this is awfully noobish of me.</p>
 

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