|
|
Thanks Johpoke it worked, and thanks to the other guys too for their responses.
|
|
|
|
|
i have a file which contains hex values. i want to convert that to human readable form. please give me some leads.
|
|
|
|
|
try itoa function for more help LOOK MSDN
|
|
|
|
|
Chandrasekharanp wrote: i have a file which contains hex values. i want to convert that to human readable form. please give me some leads
hex format is human readable. Do you mean a binary file (as opposite to text one)?
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.
|
|
|
|
|
ya right... i am sorry for the wrong query.. i need to read it from a file and convert that to ascii and then print it to another file.
|
|
|
|
|
Oh,that's not difficult, for instance:
Supposing ANSI build and error handling left to the reader
FILE * fpin = fopen("MyBinaryFile.foo","rb");
FILE * fpout = fopen("MytextFile.txt","w");
int c;
int count = 0;
while ( (c=getc(fpin)) != EOF )
{
fprintf(fpout, "%02x ", c);
if (count % 16 == 15) fprintf(fpout, "\n");
count++;
}
fclose(fpin);
fclose(fpout);
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.
|
|
|
|
|
|
Chandrasekharanp wrote: thanks GURU!!!!!!
Oh, I'm not.
Anyway, you're welcome.
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.
|
|
|
|
|
Hello,
I have one structure contains char * variable. I want to store the CString data to char* variable.
struct _iobuf {
char *_ptr;
int _cnt;
char *_base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
char *_tmpfname;
};
I have one CString variable like m_Username. I want to store m_Username to char *_base.
Could you please help me how to do.
|
|
|
|
|
_base = m_userName.GetBuffer
or
_base = new char[]
strcpy(_base, m_userName.getbuffer)
|
|
|
|
|
struct _iobuf {
char *_ptr;
int _cnt;
char *_base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
char *_tmpfname;
};
typedef struct _iobuf FILE;
FILE *fleCredentials;
fleCredentials = fopen("credentials.crd", "a+");
fprintf(fleCredentials, "%s ",(LPCTSTR)m_Username );
Problem:
========
Only one character of "m_Username" has to be stored in the "credentials.crd". I would like to store the fullname into the file.
Help to proceed further.
|
|
|
|
|
Sunil Shindekar wrote: _base = m_userName.GetBuffer
The above is a mistake, because, unless you want to lock the CString internal buffer forever, then you have to call ReleaseBuffer method, afterwards the _base pointer becomes garbage, please read documentation http://msdn2.microsoft.com/en-us/library/kt26tkzx(VS.71).aspx[^].
Sunil Shindekar wrote: _base = new char[]
strcpy(_base, m_userName.getbuffer)
Better, but still mistakes. You don't need at all GetBuffer , to do this (and you aren't calling ReleaseBuffer afterwards), the LPCTSTR cast operator is enough.
Furthermore you don't specify character array size.
And, finally, you're supposing that it is an ANSI build.
Is It enough?
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.
|
|
|
|
|
Provided it is an ANSI (not UNICODE build, you can
do:
CString strFoo("foo");
struct _iobuf iobuf;
iobuf._ptr = new[strFoo.GetLenght()+1];
if (iobuf._ptr)
{
strcpy(iobuf._ptr, strFoo);
}
...
...
if (iobuf._ptr)
{
delete [] iobuf._ptr;
}
However, I suggest, if you can, to refactor a bit you project (i.e. avoiding such a mixing of string classes and character arrays.
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.
|
|
|
|
|
I think it is an interface so he had to do such crappy things. But interface should have the buffer, because it wants the data, and knows when to release the memory to avoid leaks.
Greetings from Germany
|
|
|
|
|
Hi all,
Can anybody tell me how can i get temp folder path.
Thanks in advance
|
|
|
|
|
|
neha.agarwal27 wrote: Can anybody tell me how can i get temp folder path
GetTempPath
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
Or,
getenv("TEMP");
(type set in cmd for more vars)
//Johannes
|
|
|
|
|
Hello All,
I am changing the cursor position for inserting,updating and deleting the text in a text box control.
I am able to get the cursor position pertaining to the current cursor location though.
Please suggest me the way to find the text pertaining to the cursor.
Thanks and Regards.
Amar.
|
|
|
|
|
From VC++ Help:
<br />
CEditView::GetSelectedText <br />
void GetSelectedText( CString& strResult ) const;<br />
<br />
Parameters<br />
strResult: A reference to the CString object that is to receive the selected text.<br />
<br />
Remarks<br />
Call GetSelectedText to copy the selected text into a CString object, up to the end of the selection or the character preceding the first carriage-return character in the selection.<br />
A tip... Try checking the help. Go to index view, write the name of the control and at the bottom of the help text usually is "CLASS MEMBERS" link. With all the possible things you can do by default with that control/class.
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
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Friends,
I wanted to know your suggestions on the following:
There is an MFC application with TCP/IP connections(CAsyncSocket) to connect to machines that send out a string when the user presses a button there.
Now what do you think is the probablity(Yes/No/%) that the string is not received by the software when they are connected on LAN??
Or
Is it that there is absolutely no chance of missing(I dont think so though)
Assumptions:
Physical connections, cabling are proper and never break.
|
|
|
|
|
yashveer wrote: Now what do you think is the probablity(Yes/No/%) that the string is not received by the software when they are connected on LAN??
The target machine will either receive the data or it won't.
yashveer wrote: Is it that there is absolutely no chance of missing(I dont think so though)
There's always the possibility that the target machine could not receive the data.
"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
|
|
|
|
|
is there any diffrence working on windows 2000 and windows NT.
|
|
|
|
|
There are differences of course.
But for instance, there are more differences between Windows 2000 and Linux (i.e. IMHO you have to reformulate a bit your rather vague question).
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.
|
|
|
|