|
I would just rearange it a little:
#include <string>
#include <sstream>
std::ostringstream strm;
strm << "I got " << marks << " marks" << std::ends;
std::string strMarks = strm.str();
|
|
|
|
|
How can we find the min / max values of a particular data type:
ex.. what is the minimum or maximim value, that can be represented by DWORD
|
|
|
|
|
try these:
<br />
ULONG_MAX,<br />
LONG_MAX, LONG_MIN...<br />
see limits.h in MSVC
|
|
|
|
|
Has anyone noticed the "Summary" tab in the file-properties dialogue (RMB on some file, for e.g a .doc or a .mp3)?
There are entries for things like "Title", "Category", "Comments" etc
You cannot use these items in a normal search, so my question is how to access these extra properties of a file programatically so that one could search for all files that (say) have a "Category" of "BACKUP:OK" for e.g.
It's like the file-system is a Table in Access and these are 'fields' but you can't use them for filtering properly.
Hope there is some idea out there!
Bats
;}
|
|
|
|
|
http://support.microsoft.com/default.aspx?scid=KB;en-us;q186898
|
|
|
|
|
Thanks for the link - I am looking at it now !
Bats
:}
|
|
|
|
|
Ok - compiled that MS example and it works fine for MS type apps, but not for anyhing else. (e.g mp3, oggs)
Is there a more general way to access these 'extra' properties via C++ ?
Thanks
Bats
:}
|
|
|
|
|
One thing that I haven't seemed to get is the difference between *variable and **variable. Can anybody tell me the difference? Thanks.
|
|
|
|
|
One is a pointer, the other is a pointer to a pointer.
int * n;
represents the memory address where space is allocated for an int.
int ** n;
represents the memory address which holds a memory address which has enough space for an int. Therefore with a ** you can create a 2D array.
int **n = new int * [20];
for (int i = 0; i < 20; ++i)
n[i] = new int [10];
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Thank you. I know what a pointer is, but the ** was what was confusing to me. That makes a lot of sense then - basically in your above example you're allocating enough space for your second pointer to reference 20 other integers, and then set each of those integers to be arrays with ten elements each. That was very helpful.
|
|
|
|
|
I am new to C++ but:
*x is a pointer. x is actually an address. *x means "look inside that address"
so **x is just *(*x) - do the brackets first : ("look inside" x) and then do it again.
so if x was address:1776 then *x gives as some other value - say 2789 (the contents of 1776) and then * again looks inside 2789.
In old basic terms its peek(peek(x)) and in (bad) assembly its [[ax]]
Right, that confused even me!
|
|
|
|
|
I like to set it straight with the terms:
pointer, address of, reference, de-referenced value, and value. i.e.:
say:
int x = 5;
int* px = &x;
int** ppx = &px;
int x_val_raw = x;
int x_val_from_px = *px;
int x_val_from_ppx = **ppx;
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Nice explanation, you get a 5.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
And to only think that 2 years ago I couldn't even spell c++ I really owe it all to CP!
(well deserves some credit too...)
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Now hold on a second.
You said:
int x = 5; // initializes a variable int to value
int* px = &x; // initializes a "pointer to int"
But that's not exactly true.
int x;
int *y = x;
Now y holds the physical address for x - the dereference "&" is contradictory. To dereference, LATER ON, you could say &y. So if you said:
int* y = &x;
You would actually get a compilation error because you're trying to assign a memory location to an integer variable. The & character dereferences a variable and that's why you see variables being passed as parameters to functions like so:
void mod(int &x, int &y)
{ x=x%y return;}
This actually changes the value of the memory location at x without having to return the value at the end of the function.
|
|
|
|
|
wait wait wait...
first, you mis-quoted:
David Southard wrote:
int x = 5; // initializes a variable int to value
int* px = &x; // initializes a "pointer to int"
what I said was
int* px = &x;
------- --
| |
| |- read "Address of x"
|
|- read "a variable 'px' of type 'pointer to int'"
This is in fact different to what you said:
David Southard wrote:
The & character dereferences a variable and that's why you see variables being passed as parameters to functions like so:
void mod(int &x, int &y)
This (int& x) is not a "pointer to int" but is in fact a "reference to int".
Consider the function:
func(CString* pszString, CString& szAnotherString)
{
pszString->Format("A String");
szAnotherString.Format("Some String);
}
note that the "pointer to string" (pszString) requires pointer notation for operations, however the reference to the string (szAnotherString) is just that: a "reference" to (not a copy of) the origional string.
My term "de-referencing" is not to be confused with a "reference to". That is why I am picky where and when I put the * and & modifiers on things. When I declare a pointer to a type, I always put the * modifier at the end of the type. And likewise when I declare a reference. This is different than when I de-reference a pointer or get the "address of" something else. Try this in a console app:
int main(int argc, char* argv[])
{
int x = 5;
printf("\nThe value x initially has the value %d", x);
unsigned long physical_address_of_x = reinterpret_cast<unsigned long>(&x);
int& reference_to_x = x;
int* pointer_to_x = reinterpret_cast<int*>(physical_address_of_x);
printf("\n\nWe are now setting reference_to_x = 12\n");
reference_to_x = 12;
printf("\nThe value x is located at 0x%X and now has the value %d.", physical_address_of_x, x);
printf("\nThe reference to x is located at 0x%X and has the value %d.", &reference_to_x, reference_to_x);
printf("\nThe pointer to x is located at 0x%X and points to location 0x%X.", &pointer_to_x, pointer_to_x);
printf("\nThe pointer to x, when de-referenced yeilds the value %d\n\n", *pointer_to_x);
return 0;
}
I hope that clears things up.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
David Southard wrote:
int x;
int *y = x;
Now y holds the physical address for x - the dereference "&" is contradictory. To dereference, LATER ON, you could say &y. So if you said:
int* y = &x;
You would actually get a compilation error because you're trying to assign a memory location to an integer variable.
BTW, the reverse is true. int* y = &x is valid, int* y = x is not. (Well, as long as you aren't using VB anyway )
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Dear all member,
I read messages on GDI+ and find it interesting, butt I cannot try it out. The reason is that I cannot download 200 MB SDK from Microsoft with my 28.8 KB.
Can anyone help? Please send me a zip file with all the needed file for GDI+ programming.
Many thanks,
|
|
|
|
|
Repeating what I told you before you posted this again, it does not work. There are people who have done this and you can find them with google, but you'll end up back at my articles asking why it won't run smoothly. You really need to get the full SDK on CD from Microsoft. It's something you need anyhow, unless you have VS.NET ( in which case you would not need anything and would not be asking ), or you want to write software targetted at Windows 95. It won't take long to find another API call you wish you could use, but cannot because you need the PSDK.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
I got the SDK CD from MS for $US 8.95 shipping included. It took about a week for them to mail it to me.
Why don't you try that?
Jeff Patterson
Programmers speak in Code.
http://www.anti-dmca.org[^]
|
|
|
|
|
Hi,
I just want to change the tooltip text for window close button.I can't find anything in the resource.From where the text is been taken for that?
Regards
Neha
|
|
|
|
|
Majid Shahabfar wrote:
In fact how can I create a file in a folder that I don't have write permission?
How can you drink water from a glass that does not have any water?
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Im pretty decent when it comes to c++ programming, but im working on my first windows program right now and i cant, for the life of me, figure out how to take what the user enters in an edit box and hold the data in a string. im sure theres a function that does it somewhere, i just dont know it. could someone help me out please?
|
|
|
|
|
There are two, GetWindowText() and GetDlgItemText() . You'll probably find the second one easier. You pass it the handle to the edit's parent window (which is usually a dialog, thus the name of the API) and the ID of the edit control itself, along with a character buffer. The API stores the text in the buffer.
--Mike--
Friday's GoogleFight results: Britney Spears 2,190,000 - Erica Weichers 23
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Michael Dunn wrote:
Britney Spears 2,190,000 - Erica Weichers 23
LOL !!! What's GoogleFight ? Did you try Kate Winslet ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|