• Advertisement
Sign in to follow this  

file stream problem

This topic is 3350 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello, I have this stu... problem which's reason I can not find. #include <fstream> #include <iostream> using namespace std; ... ifstream bmpsource(path,ios::in,ios::binary); long width=0; char c='l'; bmpsource.get(c); // here I get the first character in file successfuly while (bmpsource >> width) width++; ... I successfuly get the first character in file by bmpsource.get(c) but the problem is that program never enters while cycle body.The file is large enough. Why >> operator fails? This is the only code where I use iostream library. There is no relevant code around it. Please tell me somebody why this st.. >> operator fails. Where are the good old times of stdio?

Share this post


Link to post
Share on other sites
Advertisement
Well, the obvious answer would be that whatever is after your first character isn't a text formated number. operator>> used on streams is for text IO.

Share this post


Link to post
Share on other sites
ifstream operation >> reads a formated number.
For reading a bitmap header you are going to have to use
ifstream::read() to get your data out.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement