Skip to main content
gamedev.net
🔒 Locked

file stream problem

Started by JohnnyCode Dec 19, 2008 at 10:26 AM 1 replies 750+ views
Original Post
JohnnyCode
JohnnyCode
hello, I have this stu... problem which's reason I can not find. #include #include 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?
SiCrane
SiCrane
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.
KulSeran
KulSeran
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.