ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
error C2676: binary '>>' : 'class std::basic_ostream<char,struct std::char_traits<char> >' does not define this operator or a conversion to a type acceptable to the predefined
could this be the problem?
I'm still guessing at the code you're using to get that error, but I think you need to do:
cout << indata.rdbuf();
Not:
indata >> cout;
This is because streams expects to work with data or stream-buffers, rather than a stream.
There is quite a bit of code there and I'm not certain at which point you are getting the error. Can you tell us what error you are getting (i.e what gets printed out to the console), then we can see at which line this is being generated.
I am getting the error line
"Failed to get number of gridpoints"
That means that the is_open didn't cause an error. I changed the filename so that I tried to open a file that didn't exist and the is_open caused the problem. This could only mean that the Bonavista.con is actually opening. The problem has to be that it cannot read the file.
In addition to that I substituted Allroad.con where Bonavista.con was just to see if any file could be read, and it didn't work. But I already opened Allroad.con and got information from it. :P ahhhhh
I am getting the error line
"Failed to get number of gridpoints"
That means that the is_open didn't cause an error. I changed the filename so that I tried to open a file that didn't exist and the is_open caused the problem. This could only mean that the Bonavista.con is actually opening. The problem has to be that it cannot read the file.
yes.. i told you this with my first post in this thread..
did you try hiveminds solution on your original datafiles in their original locations?
Divide and conquer is the key to successful programming, and it's clear you haven't done that. First you should write a function that opens the allroad.con file. When you have *tested* that it works, extend the function to read a file name. When you have *tested* that it can read the name, you close the file (if you don't need it anymore), then the next step is to write a function that opens a file with name that you just read. Then you test that and the next step is to test if you can read from the second file and so forth. Divide and conquer. Build your program from nothing to completeness by adding small parts (modules, functions, classes whatever) that can be tested independently. Each time you add something, you test again to see if it works. That way you see what's working and what's not.
Hivemind thats what I was doing.
Testing every step of the way, each time I would test to make sure each piece of data was collected.
Thanks for you time and help guys.
Solution: When I would close the first file data would stay on the stream. To solve this I used the clear function and it worked. I figured it out by adding a second ifstream called inData2 and it worked. But hivemind you only used one ifstream so...who knows. Maybe you now know what I was doing wrong? was the close() working properly?
If the fail bit is set all ops except clear are no-ops until the fail bit has been cleared. But you shouldn't have to get into a situation where the fail bit is set if you perform your reads and writes properly.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.