|
And how did you try to read?
|
|
|
|
|
//m_Path=input path
//m_Path2=output path
fstream rfile(m_Path,ios::in|ios::binary);//input file
fstream wfile(m_Path2,ios::out|ios::binary);//output file
//SeekPos is a starting location from where i start reading.
//SeekPos is a ending location till that i read.
char buffer[200000];
for(SeekPos;SeekPos<=SeekPos2;SeekPos++)
{
//rfile.get(ch);//if i read as character wise.
//wfile.put(ch);
rfile.read(buffer,sizeof(buffer));read from buffer
wfile.write(buffer,sizeof(buffer));
wfile.flush();
rfile.flush();
}
rfile.close();
wfile.close();
|
|
|
|
|
vijaylaxmi wrote: rfile.read(buffer,sizeof(buffer));read from buffer
wfile.write(buffer,sizeof(buffer));
Maybe you should start with a less ambitious project until you learn about return values and such.
Have you considered something like:
std::istream i = rfile.read(buffer, sizeof(buffer));
wfile.write(buffer, i.gcount());
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
|
Dont need to repeat your question.
|
|
|
|
|
Hi ALL,
I doing project in VC++ 6.0 in which i am creating web page
tool. This tool is used to create web page. I want to add the feature of creating multiple web pages at a time, same like MS front page. So is it possible to create multiple web pages and save them in SDI application. please let me know whether it is possible or not.
Thanks in Advance
at
|
|
|
|
|
how to check the current position of a file handle is EOF or not, the file handle is opened using CreateFile() API.
my project type is Win32 Application
thanks
|
|
|
|
|
You can use of CFile::Seek for get current position.
|
|
|
|
|
That's MFC Hamid, you're cheating!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
CPallini wrote: That's MFC Hamid, you're cheating!
Maxwell Chen
|
|
|
|
|
|
IMHO you have to perform a reading operation and check ReadFile return value and its out parameter lpNumberOfBytesRead , MSDN [^] states:
If the return value is nonzero and the number of bytes read is zero (0), the file pointer is beyond the current end of the file at the time of the read operation.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Hint: SetFilePointer will help you.
|
|
|
|
|
nitin3 wrote:
how to check the current position of a file handle is EOF or not, the file handle is opened using CreateFile() API.
It depends on the operaton most recently performed on the file (handle). As has been stated already, ReadFile() will return a value indicating if the requested number of bytes were read. If not, then you know that EOF was encountered.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Give you a MSDN sample:
The following code example tests for end-of-file for a synchronous read operation.
bResult = ReadFile(hFile, <br />
&inBuffer, <br />
nBytesToRead, <br />
&nBytesRead, <br />
NULL) ; <br />
if (bResult && nBytesRead == 0) <br />
{ <br />
}
A Chinese VC++ programmer
|
|
|
|
|
Hi all
<br />
<br />
CImageList imageList; <br />
<br />
imageList.Create(size.cx, size.cy, ILC_MASK | ILC_COLOR24, 0, 1 <br />
imageList.Add(&myBitmap, RGB(255,255,255<br />
<br />
CPoint pt(20,20); <br />
<br />
imageList.Draw(&dc,0,pt,ILD_TRANSPARENT);<br />
These are myself's picture code in OnPaint,
at the (20,20), I put an other control(button or edit), and that the other control had covered myself's picture.
How can let myself's picture cover other control?
|
|
|
|
|
You need to draw the image over other controls?
|
|
|
|
|
From where are you doing this drawing? Can you edit control or button be moved to another location? Can the drawing be done elsewhere on the dialog? Rather than draw directly on the dialog, can you draw on a static control or a button instead?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Control windows on the dialog are higher in the z-order than the
dialog window itself so they get painted later.
You need a window higher in the z-order than the control you
want to paint over (see DavidCrow's reply).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Maybe you should write drawing code in the control's OnPaint function or OnEraseBkgnd or somewhere like that
A Chinese VC++ programmer
|
|
|
|
|
I have three bcg control bars in my CBCGPFrameWnd derived class CMyBCGPFrameWnd :
CBCGPStatusBar m_wndStatusBar;
CBCGPToolBar m_wndToolBar;
CBCGPTabbedControlBar m_wndTabbedCb;
In CMyBCGPFrameWnd::OnCreate , I create the three bars, and want to hide them using:
m_wndTabbedCb.ShowControlBar(bShow,TRUE,FALSE);
m_wndToolBar.ShowControlBar(bShow,TRUE,FALSE);
m_wndStatusBar.ShowControlBar(bShow,TRUE,FALSE);
But only m_wndTabbedCb hides.
I made a test by toggling show/hide state in a button command, all is ok.
And if not use bcg, MFC's ShowControlBar is also ok.
How to deal with it?
Thanks.
modified on Friday, January 11, 2008 2:07:29 AM
|
|
|
|
|
Hi all,
Here is the way I handle error codes in my applications using "printf" c-standards.
printf("Error in recording data. GetLastError reports %d\n", GetLastError());
I want to do this formating using standard C++, mean using "cout" function. How can I do that formating.
I appreciate your help all the time...
Eranga
|
|
|
|
|
#include <iostream>
std::cout << "Error in ... reports " << GetLastError() << std::endl;
Maxwell Chen
|
|
|
|
|
Thanks a lot.
Oki, here is quite similar problem. I want to write some data to a file. First I include header to a file.
outFile << "File Name\tGroup ID\tDate Created\tDate Last Access\tFile Size\tNo. of Messages\n\n";
Then write there relevant values to it as follows.
outFile << strName << "\t" << strID << "\t" << osCre.str() << "\t" << osAcc.str() << "\t" << iSize << "\t" << mesCount << endl;
But after writing it both headings and values are not aligned with each other correctly. How can I format that.
I appreciate your help all the time...
Eranga
|
|
|
|