|
try strlen (tempBufferWrite) inside your write function.
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
You mean set the buffer size to length of the string(text)?
Eranga
I appreciate your help all the time...
|
|
|
|
|
mmm,
you are writing "text of letters" (16 chars including '\0'), but you have actually 256 bytes in the buffer and is not a pointer so the size is fix to you init value. That means the rest is going to be written with waste values.
Try:
void CSRFToolDlg::OnBnClickedWrite()
{
char* tempBufferWrite = NULL;
tempBufferWrite = new char[256];
tempBufferWrite = "text of letters";
openFile.Write(tempBufferWrite , sizeof(tempBufferWrite)) ;
openFile.Flush() ;
}
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Seems it works. Thanks.
Now I'm going to slightly change it with dynamic text, like text from control box. I come back here if I got any issue there.
Eranga
I appreciate your help all the time...
|
|
|
|
|
Nelek wrote: tempBufferWrite = new char[256];tempBufferWrite = "text of letters"; //or something longer, it should be the same
This is for what?
- NS -
|
|
|
|
|
mmm, I just made some changes but leaving his point of view.
Anyways, if it is not correct, or it is useless... instead of just ask "this is for what?" would be better to say, "this is not right, you should use...", so I would learn as the same time I try to help
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Eranga Thennakoon wrote: void CSRFToolDlg::OnBnClickedWrite()
{
char tempBufferWrite[256] = {0} ; // or {}
openFile.Write("text of letters", sizeof(tempBufferWrite)) ;
openFile.Flush() ;
}
instead of
sizeof(tempBufferWrite)
there you put strlen(tempBufferWrite)
thats it.
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
chandu004 wrote: there you put strlen(tempBufferWrite)
That would equate to 0 , which is obviously wrong. The second argument to Write() should be the number of bytes in the first argument.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
the length of hte string should obviously be the number of bytes in that string right??!
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
How you choose to say it is up to you, but the second argument to Write() must be the number of bytes in the first argument.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
please tell me what is the first argument, here and what is its size.
iam very sure that you may be right, but please let me know what is that wrong i have done.
thank you.
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
chandu004 wrote: please tell me what is the first argument...
In your example here, the first argument is the string literal "text of letters".
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
yah yah
i got it by seeing the nelek's post.
thank you very much(for both of you) for correcting me.
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
In this case won't work, because the tempBufferWrite is 256 chars long, but the string that is being written in the file is "text of letters" (16 chars), and note that there is no string to have length of. The code gives the "..." directly, not going through the buffer.
char tempBufferWrite[256] = "Test of letters" ;
openFile.Write(&tempBufferWrite, strlen(tempBufferWrite)) ;
That should work. What you proposed just changing sizeof with strlength must not.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
thanks for the analysis,
Nelek wrote: char tempBufferWrite[256] = "Test of letters" ; // or {}openFile.Write(&tempBufferWrite, strlen(tempBufferWrite)) ;
That should work
i was thinking that, &tempBufferWrite is used in the write,
i didnt observe some other readstring in that place.
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
Thanks,
Than mean strlen get the length of CString.
Eranga
I appreciate your help all the time...
|
|
|
|
|
anyway, just a guess: i see you're coding in C++, so why not using std::string or even CString (if using MFC) ... ?
|
|
|
|
|
Actually that readString defines as CString in my code.
Eranga
I appreciate your help all the time...
|
|
|
|
|
openFile.Write(tempBuffer, amount of data you wrote to tempBuffer); Don't pass the whole buffer length when you didn't fill that much.
DoEvents : Generating unexpected recursion since 1991
|
|
|
|
|
Actually that what I've worried about. Couldn't find any way to define the buffer length as the length of string. Actually I tried something like this.
readString.GetLength()
Eranga
I appreciate your help all the time...
|
|
|
|
|
how can i install msdn library in vc++ 6.0 ??? I'm getting a message as "Please reinstall msdn" when i click on help.....
|
|
|
|
|
Can you run MSDN individually. At the installation you have a option to combine both MSDN and Visual C++ together. If you neglect that option you have to work with them separately.
Eranga
I appreciate your help all the time...
|
|
|
|
|
You might be using newer version of MSDN, which cant be taken directly from VC6.
- NS -
|
|
|
|
|
What version of MSDN are you working with?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
The newest version of MSDN Library that still integrates with Visual Studio 6.0 is October 2001. It may still be possible to download this if you're an MSDN subscriber (although not right now as the subscriber download site doesn't seem to be working).
A very out-of-date version of MSDN Library accompanied Visual Studio 6.0 itself (labelled 'MSDN Library for Visual Studio 6.0'). However, this predates Windows 2000 and I would not recommend using it. (It was up-to-date in mid-1998 when Visual Studio 6.0 was released!)
DoEvents : Generating unexpected recursion since 1991
|
|
|
|