IO problem

Started by
7 comments, last by spe 19 years, 10 months ago
Hi! I''m trying to open a bmp file and read the size of the picture, but somehow it doesn''t work. here is the source : #include "stdafx.h" #include <iostream> #include <fstream> using namespace std; int main(int argc, char* argv[]) { int x,y; ifstream file; file.open("BMP/pic.bmp"); file.seekg(18,ios::beg); file>>x>>y; file.close(); return 0; } the x,y variables aren''t changed at all. Could some one help me with this? Thanks ,spe JSoft@coder.hu
JSoft@coder.hu
Advertisement
the >> operators are for text files.

use read() or whatever.
What''s the sintax of read?
JSoft@coder.hu
google for istream and you''ll find lots and lots of references
Google keywords: ifstream read reference

istream::read()

--
You''re Welcome,
Rick Wong
- Google | Google for GameDev.net | GameDev.net''s DirectX FAQ. (not as cool as the Graphics and Theory FAQ)
Read is for reading an array of chars, but I need to read two ints.
JSoft@coder.hu
Do
read(&x, sizeof(int))
read(&y, sizeof(int))
I tried but I get an error coz x and y are ints and the read func. takes only a pointer to a char.

JSoft@coder.hu
JSoft@coder.hu
It works now with type casting.
Thanks for the help!

JSoft@coder.hu
JSoft@coder.hu

This topic is closed to new replies.

Advertisement