|
long is ( or was ?! ) a size qualifier for the int at the time of 16bits apps. ( samething for short ).
long and short are not really types!
Alvaro Mendez wrote:
4. On Win64, long is also 32 bits, whereas on UNIX, it's 64 bits (which is what you'd expect, and how it's represented in .NET and Java).
Are you sure ? I thought the int would be "scaled" according to the CPU ?
Max.
|
|
|
|
|
Maximilien wrote:
long and short are not really types!
although everyone treats them as such. No one ever writes signed long int when long works just as well.
--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
|
|
|
|
|
Maximilien wrote:
Are you sure ? I thought the int would be "scaled" according to the CPU ?
No. AFAIK, int remains 32-bit on Win64.
|
|
|
|
|
I believe the 64-bit CPU's coming out of Intel are still 32 bits wide in terms of their 'native' word size, but 64 bits in terms of memory addressing. int therefore stays 32 bits in Win64.
Software Zen: delete this;
|
|
|
|
|
I wrote an app that creates a web page. Now they want to print it out. The problem comes that the settings for everyones printing is set differently, ie margins, header/footer, and if print background is selected. Is there a way to send IE the paramiters I want to print for this page? Thanks in advance.
Darroll
|
|
|
|
|
I've got a control derived from the browser. My printing code looks like this -
HRESULT hr;
BSTR header_BSTR = ::SysAllocString(L"&w&b&b&p");
VARIANT header_variant;
VariantInit(&header_variant);
V_VT(&header_variant) = VT_BSTR;
V_BSTR(&header_variant) = header_BSTR;
BSTR footer_BSTR = ::SysAllocString(L"&d &t");
VARIANT footer_variant;
VariantInit(&footer_variant);
V_VT(&footer_variant) = VT_BSTR;
V_BSTR(&footer_variant) = footer_BSTR;
long index;
SAFEARRAYBOUND parameter_array_bound[1];
SAFEARRAY *parameter_array = NULL;
parameter_array_bound[0].cElements = 2;
parameter_array_bound[0].lLbound = 0;
parameter_array = SafeArrayCreate(VT_VARIANT,1,parameter_array_bound);
index = 0;
hr = SafeArrayPutElement(parameter_array,&index,&header_variant);
index = 1;
hr = SafeArrayPutElement(parameter_array,&index,&footer_variant);
VARIANT parameter;
VariantInit(¶meter);
V_VT(¶meter) = VT_ARRAY | VT_BYREF;
V_ARRAY(¶meter) = parameter_array;
hr = _Browser->ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DONTPROMPTUSER,¶meter,NULL);
if (!SUCCEEDED(hr)) {
VariantClear(&header_variant);
VariantClear(&footer_variant);
if (parameter_array != NULL) {
SafeArrayDestroy(parameter_array);
}
}
This code sets the header and footer for the page and then prints it. The _Browser value points to the IWebBrowser2 interface for the control. If I remember correctly, I found this stuff in an example in the MSDN.
Software Zen: delete this;
|
|
|
|
|
With CString, we can perform an operation something like:
CString strMarks;
strMarks.Format("I got %d marks",marks);
Can we perform similar operation using std::string ??? If yes, then how ???
|
|
|
|
|
Try this:
char buffer[200] = {0};
std::string str = "";
int i = 9;
sprintf(buffer, "\n\nThis is number: %d\n\n", i);
str = buffer;
printf(str.c_str());
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Unfortunately, you can't. In concept of C++ std library you must use streams (like as stdout, stdin and etc). This method was perfectly described by Alexandrescu in his book "Modern C++...". But personally I like to use old good method as Format. And I have invented my own function. May be it will be useful for you
string_smart Format(cstr szText,...)
{
cstr szPtr=szText;
size_t lLen;
for (lLen=0;*szPtr; ++szPtr,(*szPtr=='%') ?lLen+=10:lLen++);
string_cstr strRes(++lLen);
va_list marker;
va_start( marker, szText);
while (_vsnprintf(strRes.buffer(),strRes.buffer_size()-1,szText,marker) <0 )
strRes.reserve(strRes.buffer_size()*2);
strRes.buffer()[strRes.buffer_size()-1]='\0';
strRes.recalc_len();
va_end( marker );
return strRes;
}
This function works with my class string_smart, but it is not hard to remake it for std::string
|
|
|
|
|
Yes you can, using the stringstream class:
#include <string>
#include <sstream>
ostringstream strm;
string strMarks;
strm << "I got " << marks << " marks" << ends;
strMarks = strm.str();
--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
|
|
|
|
|
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.
|
|
|
|