Sign in to follow this  
JohnnyCode

file stream problem

Recommended Posts

JohnnyCode    1046
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
SiCrane    11839
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this