Topic: How to convert LONG (DWORD/INT/UINT) to CString and vice versa???
Author: "Laurens Koehoorn" <lhksoft@glo.be>
Date: 1996/07/09 Raw View
Hi there all,
I'm writing a program that will split large files into smaller ones,
whithout adding extra data to it, so you can put the whole thing back
together later on, using the COPY /b command of (MS-)DOS.
Because I just started programming using MSVC++ (2.0) I've done the most
things out of books. But now, when I'm writing my first own program
(32-bits, so it will be compatible with Win95's/WinNT's long file names) I
came to a major problem.
I can't convert integers (SHORT ; INT ; UINT ; WORD ; DWORD ; LONG) to
CHAR[] and vice versa (an integer in char[]/cstring to a real integer).
I first tryed to use "wsprintf(LPTSTR, LPCTSTR, ...) like this:
{
// ...
char a[128]; char b[128];
DWORD c=360;
a[0] = '\0';
strcat(b, "FileSize should be: %luKb");
wsprintf(a, b, c);
}
As a result I got the following: b = "FileSize should be: 104Kb"
Even if I tryed to skip the l (...%u... instead of ...%lu...) I came to
same value.
I know how to overcome this in Turbo Pascal (Borland).
To convert a string to an int I used the function:
function val(a : string, b : integer, var c : integer) : integer;
(In C++ it should look like this:
int val(LPCTSTR a, int b, int c=0);
)
And to convert an integer (short .. signed long) I would use:
procedure str(i : longint, var s : string);
( In C++ : this looks like this:
void str(signed long i, char* s);
)
There should exist a routine of this kind in C++, isn't it?
If you know the name of the class in MFC or the name of the function,
please tell me. If you have a small source code for me (assembler/C++)
please mail it to me.
I'm stucked. And I know from experience that no programmer is happy when
he can't go further programming, because he don't know how to solve some
kind of 'irritating' problem.
I know the books won't help me (I've got 5 books about MFC), so I try the
www. There should be anyone who can help me...
Desperatly waiting for a reply,
LhKSoft,
Laurens...
Cu.
PS: Sorry for my bad English...
{ This guy could use some good, solid advice. -mod}
--
lhksoft@glo.be
[ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
[ about comp.lang.c++.moderated. First time posters: do this! ]