|
Dear All,
I have some problem in converting Hex string to ASCII value. For example, I have Hex string of "50" and I would like to display the ASCII equivalent "P".
If i know the value to convert i can just use
CString str;
str = "\x50";
to convert to ASCII value. But the Hex value is entered by the user. So I dont know how to do that.
Can Anyone please help me in this?
Thanks in Advance.
Regards,
Ram
|
|
|
|
|
Would ::strtol() help you in this situation? Info here.[^]
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
Can you please give me an example?
Regards,
Ram
|
|
|
|
|
Ram Murali wrote: Can you please give me an example?
I provided a link in my previous post to MSDN.
Follow it and you will find another link in the MSDN article to an example.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
But this function is to convert str to long. how can i get a character?
Regards,
Ram
|
|
|
|
|
char cAsciivalue = nlong;// the long value u got
nave
|
|
|
|
|
Ram Murali wrote: But this function is to convert str to long.
Of course; and that return value is the ASCII code for the character.
E.g. if your user has input "50" the long return value of ::strtol() will be 0x50, which is 80 in decimal format, and this is the ASCII character code for 'P'.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
Thanks for your effort to solve my problem. Its working well. Thanks again.
Regards,
Ram
|
|
|
|
|
Ram Murali wrote: For example, I have Hex string of "50" and I would like to display the ASCII equivalent "P".
CString strHex = "0x50";
char *pEnd;
printf("%c\n", strtol(strHex, &pEnd, 16));
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks a lot. Its working well.
Regards,
Ram
|
|
|
|
|
Hi,
How we can draw a slanding rectangle or ellipse using VC++?
I tried GDI+ but its quit time consuming can any body suggest an alternative method
Tony
|
|
|
|
|
|
Try code like this:
CPaintDC dc(this);
static const double pi = 4.0*atan(1.0);
static const double degToRad = pi/180.0;
static const double angle = 45.0*degToRad;
static const int cx = 200;
static const int cy = 200;
static const float cosAngle = static_cast<float>(cos(angle));
static const float sinAngle = static_cast<float>(sin(angle));
static const XFORM xf =
{
cosAngle, sinAngle,
-sinAngle, cosAngle,
-cx*cosAngle+cy*sinAngle+cx, -cx*sinAngle-cy*cosAngle+cy
};
int oldMode = ::SetGraphicsMode(dc.GetSafeHdc(), GM_ADVANCED);
::SetWorldTransform(dc.GetSafeHdc(), &xf);
dc.Ellipse(cx-100, cy-50, cx+100, cy+50);
::SetGraphicsMode(dc.GetSafeHdc(), oldMode);
Steve
|
|
|
|
|
Hi all.
I must write service for NT, can some one tell me where I can find good book to read about it.
thanks all.
|
|
|
|
|
You can see articles on the codeproject about it
|
|
|
|
|
|
Hi,
I work on an xml project using xerces integrated to the MS VC++ 6.0 environment (msdev). I need to integrate xerces with MS Visual Studion 2003 (devenv).
The following are the setup options I create with the VC++ 6.0
a. Project Setting -> C/ C++ tab -> Category : Preprocessor ->Additional Include Directory :
b. Project Setting -> Link -> Category : Input -> Object/ Lib Modules : Xerces-c_2D.lib and Addtional lib path :
Xerces works fine with this.
When I try the same with MS VS 2003, i get linker errors indicating that there is a clash between the MSXML and xerces' functions definitions. What Should I do to resolve this issue. Please help
|
|
|
|
|
Hi All,
i have a vc++client and i'm using com components having business logic.
Problem:
i'll not close the client application.
but the virtual memory accupied by the process is not freed.
when it reaches maximum of virtual memory client application crashes.
please give me the solution what to do avoid crashing.
Thanks in Advance.
Prashanth.
-- modified at 2:58 Friday 2nd February, 2007
|
|
|
|
|
voorugonda prashanth wrote: the virtual memory accupied by the process is not freed.
You are experiencing memory leaks.
Are you using new (or, worse, malloc ) without delete (or free )?
Are you properly using delete[] when deleting an array?
Are your COM-Components OK and properly releasing when no longer used?
Are you sure you are releasing them?
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
jhwurmbach wrote: Are you using new (or, worse, malloc)
Why would using malloc be wrose than using new ? What do you think new is calling internally?
|
|
|
|
|
WalderMort wrote: Why would using malloc be wrose than using new?
malloc is very fine - in C-code.
With C++ and objects, you better use new .
WalderMort wrote: What do you think new is calling internally?
How could I know? Why would I care?
Thats an implementation detail that can (and will!) change.
I have even seen an heap manager to be written from scratch.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
hi,
i'm not using malloc or new in my application.
i'm using only vectors of class objects allocated on stack itself.
i dont see any problem with vectors of class objects allocating on stack.
steps:
1) client application talks to the component
2) which internally talks DBHandler component which connects to SQL Server and returns the result back.
3) the result i'm storing in vectors for processing.
4) return back to the client.
i'm not able get what exactly the problem is??
|
|
|
|
|
voorugonda prashanth wrote: dont see any problem with vectors of class objects allocating on stack.
Only when these objects are correctly copy-construcable.
All objects in STL vectors will be copied when needed, and the old instances deleted.
Some object may not properly delete their allocated resources when simply deleted and need to have a special deletion routine been called.
Poor design, that.
You say that you store results of an SQL-transaction. When this result does not hold a link to the SQL-connection and is simply data stored in members and not new ed, I am also not able to get where the problem is.
-- modified at 9:08 Friday 2nd February, 2007
typo
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
A huge difference is that for an object the constructor is not guaranteed to be called when using ::malloc() , but it's guaranteed to be called when using new .
The same goes for ::free() and delete .
Read Stroustrup's FAQ for more info: clickety[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
I know what the difference is between the two, but I would like to know why he thinks using malloc is worse than using new. Granted, using new has become the standard in c++ code, but there are instances where using malloc has proved to be better, take the resizing of dynamic arrays for example or needing to allocatate an instance without calling the c'tor ( not that I can think of a valid reason for doing this ).
|
|
|
|