|
So, what is the problem ? Your data is there but if you try to display it with a function that waits for a string, you won't be able to see past the zero char. Just send your buffer and it will work. You need to remember the size of your string of course because strlen won't work.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
|
Aljechin wrote: char szSource[23] = {"Before\0After"};
char szDest[23];
ptr = memcpy(szDest,szSource,22);
printf("%s %d",szDest,strlen(szDest));
<br />
char szSource[23] = {"Before\0After"};<br />
char szDest[23];<br />
<br />
std::copy(szSource, szSource + 23, szDest);<br />
However, as Cedric already noted, don't expect that printf and strlen show the whole thing if you have embedded zeroes.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Thank you so much. I will try this.
![Rose | [Rose]](https://codeproject.freetls.fastly.net/script/Forums/Images/rose.gif)
|
|
|
|
|
Hi all
How can I get file size in mega bytes ?
Is there any good API, for this ?
I have a MFC prpject.
thank you.
|
|
|
|
|
big_denny_200 wrote: Hi all
How can I get file size in mega bytes ?
Is there any good API, for this ?
GetFileSizeEx() for reteriving size of File and convert that into MB by divinding it by 1024 *1024
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi ThatsAlok,
How are you?
and StrFormatByteSizeA
whitesky
|
|
|
|
|
WhiteSky wrote: How are you?
Fine
WhiteSky wrote: nd StrFormatByteSizeA
Will try!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
WhiteSky wrote: StrFormatByteSizeA
Thanks for Api!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
yo're welcome Mr Alok Gupta
whitesky
|
|
|
|
|
WhiteSky wrote: welcome Mr Alok Gupta
Even Alok will do
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
open the file using CFile
then call "GetLength"
it will give u size in bytes divide it by (1024*1024) ( im not sure this calculation is correct)
SaRath.
"Don't Do Different things... Do Things Differently..."
|
|
|
|
|
SaRath C wrote: open the file using CFile
Not a good idea as Open() is an expensive call, not to mention that it could easily fail if another process has the file open.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
|
my code:
BEGIN_EVENTSINK_MAP(CBrowserPage, CDialog)
//{{AFX_EVENTSINK_MAP(CBrowserPage)
ON_EVENT(CBrowserPage, IDC_EXPLORER1, 271 , NavigateError, VTS_DISPATCH VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PBOOL)
ON_EVENT(CBrowserPage, IDC_EXPLORER1, 252 /* NavigateComplete2 */, OnNavigateComplete2Explorer1, VTS_DISPATCH VTS_PVARIANT)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
OnNavigateComplete2Explorer1 can work,
NavigateError can't work,why?
my ie is 6.0
thanks!
|
|
|
|
|
had got it ,
ON_EVENT(CBrowserPage, IDC_EXPLORER1, 271 , NavigateErrorExplorer1,VTS_DISPATCH VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PBOOL)
can work
thanks
|
|
|
|
|
Hi again buddies
Can anyone help me with a couple of questions on CString
i'm trying to use it for the first time
CString str("Ma%"); //CString' : undeclared identifier(i include string)
also how can i convert a string to CString and vice versa
Thanks a lot
|
|
|
|
|
CString is a MFC (or ATL) class. if you don't have a MFC project, you won't see it.
did you create a console project ?
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
U need MFC support for the application.
CString is defined at "Afx.h"
if add support to for MFC, u can simply use the basic mfc classes.
These are the main include files.
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
in a normal MFC application, this will be included at "StdAfx.h"
SaRath
"D on't blindly follow rules you read somewhere without verifying that it makes sense for your situation!"
|
|
|
|
|
Converting string to CString
<br />
string stdStr = "Test";<br />
CString strText = stdStr.c_str();<br />
SaRath
"D on't blindly follow rules you read somewhere without verifying that it makes sense for your situation!"
|
|
|
|
|
Thanks for the reply
Yes i'm doing a console application
SARATH can u pls write again the include files that i need to use
the code was cut off
Thanks again
|
|
|
|
|
go to your project settings, add MFC support in it.
then, in your files, #include (before all other includes) the file "stdafx.h" which should have been created in your project.
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
there is a simple method I can suggest.
Create a new console.
at the Application settings, "Support MFC"
copy the code or add teh file u have implemented to this newly created workspace. it will work fine.
that is the better way
the include files are AfxWin.h and afxext.h
SaRath
"D on't blindly follow rules you read somewhere without verifying that it makes sense for your situation!"
|
|
|
|
|
Thanks alot i appreciate all the help
|
|
|
|
|
antonaras wrote: SARATH can u pls write again the include files that i need to use
the code was cut off
They're there:
#include <afxwin.h>
#include <afxext.h>
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|