Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BMP file read problem 1

Status
Not open for further replies.

Robertus

Programmer
Feb 16, 2001
81
RO
Is there anyone that could tell me why a code like this:
---------------------------------------------
CFileDialog dlg(TRUE);
FILE* fp;
char buff[512000];
if(IDOK==dlg.DoModal())
{
fp=fopen((LPCTSTR)dlg.GetPathName(),"rb");
int ch;
int i=0;
while((!feof(fp)) && (i<511999))
{
//fread(buff,sizeof(char),1024,fp);
ch=fgetc(fp);
if(ch!=EOF)buff[i++]=char(ch);
else MessageBox(&quot;EOF&quot;);
}
fclose(fp);
}
m_r.SetWindowText(LPCTSTR(buff));//m_r is a richedit control
-----------------------------------------------------------

doesn't display me anything but only the first 5 characters
from a .BMP file ??????????????
 
There can be many causes:
- the 6th character is and end-of-file caracter - causing feof to return TRUE.
- a display problem - the displayed string cannot pe shown because of some special caracters. (like FormFeed and so on).

My advice is to debug the code line by line.

Hope this helps, s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top