{"id":3896,"date":"2014-03-30T06:17:44","date_gmt":"2014-03-30T06:17:44","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-istream-collection-of-common-programming-errors\/"},"modified":"2014-03-30T06:17:44","modified_gmt":"2014-03-30T06:17:44","slug":"problem-about-istream-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-istream-collection-of-common-programming-errors\/","title":{"rendered":"problem about istream-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e29c56de40566a2169138e5f6e1add48?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nStephan Aiche<br \/>\nc++ stringstream istream libstdc++ libc++<br \/>\nWith my recent upgrade to Mac OS X 10.9 the default standard C++ library changed from libstdc++ to libc++. Since then I observe unexpected behaviour of the stringstream operator&gt;&gt;(double) documented in the code example below. In summary the libc++ seems to have problems with extracting double values from stringstreams when the double value is followed by a letter.I already checked the standard (2003) but I can&#8217;t find any specific information if extraction should work in this case or not.So I wou<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/e3xbf.jpg?s=32&amp;g=1\" \/><br \/>\nfiniteloop<br \/>\nc++ iostream ifstream istream<br \/>\nI need to write a program that reads in either from ifstream or cin, depending on parameters passed into the program at runtime.I was planning on doing the following:istream in;if(argv[1] == &#8220;cin&#8221;){in = cin;}else{ifStream inFile;inFile.open(argv[1].c_str());in = inFile;}However, istream in protected, and I can&#8217;t declare istream in. Is there a way to declare such a generic in stream?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/hDGuY.jpg?s=32&amp;g=1\" \/><br \/>\nRetsbew Nairb<br \/>\nc# c++ dllimport istream<br \/>\nI am using VS 2008 C# Windows Application.I have this DLL Import I am trying to use.[DllImport(&#8220;Mapi32.dll&#8221;, PreserveSig = true)] private static extern void WrapCompressedRTFStream( [MarshalAs(UnmanagedType.Interface)] UCOMIStream lpCompressedRTFStream, uint ulflags, [MarshalAs(UnmanagedType.Interface)] out UCOMIStream lpUncompressedRTFStream );public const uint MAPI_MODIFY = 0x00000001; public const uint STORE_UNCOMPRESSED_RTF = 0x00008000;I have a compressed string that is in CompressedRFTForm<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/9026e6869450d95205ce3b9f04153b52?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser1397417<br \/>\nc++ pointers mysql-connector istream<br \/>\nThe below function part of connector\/C++, it returns a istream*. if i just try and print it, it shows hex or a memory location because its a * type.istream *stream = res-&gt;getBlob(1);I tried to read &amp; print it with this:string s; while (getline(*stream, s))cout &lt;&lt; s &lt;&lt; endl; But this crashes with access violation though. any other way i can print it or convert to string?the value of stream before the getline:stream 0x005f3e88 {_Chcount=26806164129143632 } std::basic_istream<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/9026e6869450d95205ce3b9f04153b52?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser1397417<br \/>\nc++ mysql mysql-connector istream connector<br \/>\nI was expecting to see a short english sentence as output but i see hex value of it instread. I cannot find any information on this getblob function but i hear its what should be used for varchar columns. Before i used getString and it crashes the app, its funny though becuase it crashes after it successfully prints the sentence sometimes. However i cant have it crashing so i need to make it work with getblob, it returns an std::istream which i no nothing about. I experimented with converting is<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e9e4057554dd189e0e99250c1818c11d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nWincruzer<br \/>\nstackoverflow unhandled-exception istream<br \/>\nI&#8217;m fairly new to C++, and am trying to get the istream to work. I have a class of: class rat { private:int num;int denom; public:rat();rat(const int&amp;, const int&amp;);rat(const int&amp;);friend ostream&amp; operator &lt;&lt; (ostream&amp;, const rat&amp;);friend istream&amp; operator &gt;&gt; (istream&amp;, const rat&amp;); }; rat::rat(void) {num = 0;denom = 1; }rat::rat(const int &amp;n, const int &amp;d) {num = n;denom = d;simplify(); }rat::rat(const int &amp;n) {num = n;denom = 1; }ostre<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/377b945e05a7a786fc193c4b982468f6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nEric Kulcyk<br \/>\nc++ fread istream<br \/>\nRight now I am using istream to read in data. I have both text which I would like to read in as strings and numbers, and hashes which are read into character arrays. Since hashes are effectively random, I am hitting snags when I try to read it back in and hit EOF (which is part of the hash). Is there a way to accomplish this without resorting to fread. Also, is there a to use both istream and fread some I don&#8217;t have to parse the integers and strings by hand. Finally, what is the best way to<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/605e76902ab2298533464b5cd20c3876?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAABoucher<br \/>\nc++ file undefined ifstream istream<br \/>\nI am trying to get a shader file loader into my program. I am copying the code from http:\/\/www.opengl.org\/sdk\/docs\/tutorials\/ClockworkCoders\/loading.php under the &#8220;Loading Shader&#8221; section. I have a more simplified non-working version below.I&#8217;ve checked that I&#8217;ve included all the ifstream header files that the example from the website includes but I am getting the following errors:error C2027: use of undefined type &#8216;std::basic_ifstream&lt;_Elem,_Traits&gt;&#8217; error C2228: left of &#8216;.good&#8217; must have<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/68dfa448494635a13d602d5aedd68f4f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser619818<br \/>\nc++ istream<br \/>\nI am reading from a file into a string until I reach a delimitting character, the dollar symbol. But the input iterator is skipping whitespace so the string created has no spaces. not what I want in this case. Is there any way to stop the skipping behaviour? and if so how?Here is my test code.#include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;iterator&gt; #include &lt;string&gt;\/\/ istream iterator is skipping whitespace. How do I get all chars? void readTo(std::istream_iterator<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f819307e6e2278ee6e503dab3bc89bbe?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nm42a<br \/>\nc++ istream<br \/>\nWhen I try to compile the codeistream in; if (argc==1)in=cin; else {ifstream ifn(argv[1]);in=ifn; }gcc fails, complaining that operator= is private. Is there any way to set an istream to different values based on a condition?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2cc52e794721d1829fa825880a396283?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nEvan Teran<br \/>\nc++ istream istream-iterator<br \/>\nI&#8217;ve looked at the standard and didn&#8217;t see an obvious answer.suppose i&#8217;ve done this:std::istream_iterator&lt;char&gt; is(file); while(is != std::istream_iterator&lt;char&gt;()) {++is; }now is is at the end of the stream and is equal to std::istream_iterator&lt;char&gt;(). What happens if I increment it one more time? Is it still equal to std::istream_iterator&lt;char&gt;()? or os the result undefined?The standard explicitly states that *is is undefined behavior if is is at the end of the stream.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/ed9e8c0ff767e38f8fade11f5af00a45?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nrubenvb<br \/>\nc++ c++0x copy-constructor istream deleted-functions<br \/>\nI need help with the non-copyable nature of [io](f)streams.I need to provide a hackish wrapper around fstreams in order to handle files with unicode characters in their filenames on Windows. For this, I devised a wrapper function:bool open_ifstream( istream &amp;stream, const string &amp;filename ) { #ifdef __GLIBCXX__FILE* result = _wfopen( convert_to_utf16(filename).c_str(), L&#8221;r&#8221; );if( result == 0 )return false;__gnu_cxx::stdio_filebuf&lt;char&gt;* buffer = new __gnu_cxx::stdio_filebuf&lt;char<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d141d658cf7e561785b7f0e324d18445?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nnodwj<br \/>\nc++ istream<br \/>\nI have a switch inside a while loop. After I call option 4 three times, the program crashes the next time I input the int which decides which case to go into in the switch. I have no idea why it happens. This is the code of the while loop:void Menu::start() {Store st;int op=1,num,quantity;string name;while(op!=0){cin&gt;&gt;op;try{switch(op){case 1:{cin&gt;&gt;num&gt;&gt;name;st.addProduct(num,name);break;}case 4:{cin&gt;&gt;num&gt;&gt;quantity;st.sellProduct(num,quantity);break;}case 0:break;de<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Stephan Aiche c++ stringstream istream libstdc++ libc++ With my recent upgrade to Mac OS X 10.9 the default standard C++ library changed from libstdc++ to libc++. Since then I observe unexpected behaviour of the stringstream operator&gt;&gt;(double) documented in the code example below. In summary the libc++ seems to have problems with extracting double values from [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3896","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3896","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3896"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3896\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}