|
In my endless search for memory leaks, I've started to second-guess some things I once thought to be true. I just want to confirm something about CString here, to be certain:
Let's say I have code like this:
std::string displayStr;
displayStr = "Hello";
CString tmp(displayStr.c_str());
Do I need to free any memory here? I'm worried that perhaps in that particular usage of the CString constructor, heap memory is allocated, so I just want to make sure it isn't.
Kelly Ryan
|
|
|
|
|
When tmp goes out of scope, memory will be freed.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
How do I take each character from an array, convert it into its ascii and store the values into another array? Someone please respond. Thanks.
samita_friendly
|
|
|
|
|
a char already contains the ascii value...
char c = 'd';
int i = c;
|
|
|
|
|
But, I have an array of about 100 characters in it. How do I convert all of them into ascii?
|
|
|
|
|
One at a time. What's the problem?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
An array of characters already contains the ascii values of those characters, no conversion is necessary. If you want to copy them to another array, just loop through.
Kelly Ryan
|
|
|
|
|
If my array a[] has three characters A,B,C. If I print the array it is giving just the characters. I want 65,66,67.
|
|
|
|
|
Just print them as integers.
printf("%d %d %d", (int)a[0], (int)a[1], (int)a[2]);
Kelly Ryan
|
|
|
|
|
no need to cast into (int)
|
|
|
|
|
I like to avoid my old g++ UNIX compiler warnings
KR
|
|
|
|
|
then, prefer using static_cast<int>()
|
|
|
|
|
how do you print ? use %d instead of %c in printf()
|
|
|
|
|
did you understand my answer ? NO conversion actually NEEDED !!!
|
|
|
|
|
a simple for loop... utilizing the above ASCII conversion example for each iteration of the array
|
|
|
|
|
Thanks guys, I'll try them out.
|
|
|
|
|
hi all,
can we remove desktop icon programatically ?
venu
|
|
|
|
|
You already asked this question. Be patient.
|
|
|
|
|
Hey, we have money. We can pay for it.
We have to format a SD Data card from with-in a program. It has to be FAT16, and we don't want XP's format dialog box to come up.
We have been searching on several sites that sell C++ libraries, nothing exists! It looks like we will have to go raw and manually format the drive.
Thing is, this code has to have been written a hundred times. It doesn't seem like something we should have to write again.
Does anyone know of a library that can be purchased to do this?
Thanks for the responses - I love the Code Project site!
-Matt
|
|
|
|
|
YOu mean like this[^] ?
led mike
|
|
|
|
|
MSDN: The format is controlled by the dialog interface. That is, the user must click the OK button to actually begin the format—the format cannot be started programmatically.
|
|
|
|
|
No, that opens a format dialog.
|
|
|
|
|
|
I looked at that article and discarded it because:
) It displayed a dialog (I hadn't thought of making the dialog invisible)
) It looks like the user has to press the 'Start' button
) I'm not sure how you would force it to FAT16
-Matt
|
|
|
|