problem about istream-Collection of common programming errors
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>>(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’t find any specific information if extraction should work in this case or not.So I wou
finiteloop
c++ iostream ifstream istream
I 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] == “cin”){in = cin;}else{ifStream inFile;inFile.open(argv[1].c_str());in = inFile;}However, istream in protected, and I can’t declare istream in. Is there a way to declare such a generic in stream?
Retsbew Nairb
c# c++ dllimport istream
I am using VS 2008 C# Windows Application.I have this DLL Import I am trying to use.[DllImport(“Mapi32.dll”, 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
user1397417
c++ pointers mysql-connector istream
The 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->getBlob(1);I tried to read & print it with this:string s; while (getline(*stream, s))cout << s << 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
user1397417
c++ mysql mysql-connector istream connector
I 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
Wincruzer
stackoverflow unhandled-exception istream
I’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&, const int&);rat(const int&);friend ostream& operator << (ostream&, const rat&);friend istream& operator >> (istream&, const rat&); }; rat::rat(void) {num = 0;denom = 1; }rat::rat(const int &n, const int &d) {num = n;denom = d;simplify(); }rat::rat(const int &n) {num = n;denom = 1; }ostre
Eric Kulcyk
c++ fread istream
Right 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’t have to parse the integers and strings by hand. Finally, what is the best way to
AABoucher
c++ file undefined ifstream istream
I 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 “Loading Shader” section. I have a more simplified non-working version below.I’ve checked that I’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 ‘std::basic_ifstream<_Elem,_Traits>’ error C2228: left of ‘.good’ must have
user619818
c++ istream
I 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 <iostream> #include <fstream> #include <iterator> #include <string>// istream iterator is skipping whitespace. How do I get all chars? void readTo(std::istream_iterator
m42a
c++ istream
When 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?
Evan Teran
c++ istream istream-iterator
I’ve looked at the standard and didn’t see an obvious answer.suppose i’ve done this:std::istream_iterator<char> is(file); while(is != std::istream_iterator<char>()) {++is; }now is is at the end of the stream and is equal to std::istream_iterator<char>(). What happens if I increment it one more time? Is it still equal to std::istream_iterator<char>()? or os the result undefined?The standard explicitly states that *is is undefined behavior if is is at the end of the stream.
rubenvb
c++ c++0x copy-constructor istream deleted-functions
I 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 &stream, const string &filename ) { #ifdef __GLIBCXX__FILE* result = _wfopen( convert_to_utf16(filename).c_str(), L”r” );if( result == 0 )return false;__gnu_cxx::stdio_filebuf<char>* buffer = new __gnu_cxx::stdio_filebuf<char
nodwj
c++ istream
I 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>>op;try{switch(op){case 1:{cin>>num>>name;st.addProduct(num,name);break;}case 4:{cin>>num>>quantity;st.sellProduct(num,quantity);break;}case 0:break;de
Web site is in building