0
felisca's Avatar, Join Date: Dec 2006
Go4Expert Member
Quote:
You can construct a string-class string from a C-string directly, as in "string myString ("ABCDEFG");". To construct with a character, however, you must supply a length, as in "string myString (8, '\0');".
Thank you very much!!!!!!!!!!
I think I've done it.
One more question: Regarding double and int. Actually I don't need double, but I need 64 bit int. Do I have an option to allocate it?
0
felisca's Avatar, Join Date: Dec 2006
Go4Expert Member
Quote:
You can construct a string-class string from a C-string directly, as in "string myString ("ABCDEFG");". To construct with a character, however, you must supply a length, as in "string myString (8, '\0');".
Yes, that is not what I need.
0
Aztec's Avatar, Join Date: May 2006
Contributor
In C99, there is long long integer types, which are binary integer types at least 64 bits wide. C++ doesn't have this. You'll have to go for dynamic memory allocation or better why not use vector container. That will take care of all your shrinking and expanding of memory.
0
felisca's Avatar, Join Date: Dec 2006
Go4Expert Member
Quote:
Originally Posted by Aztec
In C99, there is long long integer types, which are binary integer types at least 64 bits wide. C++ doesn't have this. You'll have to go for dynamic memory allocation or better why not use vector container. That will take care of all your shrinking and expanding of memory.
Thank you!
I will try it.
I'm new in c++,so I need to explore all these options.
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
You need to make up your mind what the hell you want. I quote you:
Quote:
I want to get b as following:
b.size = 8 (8 bytes)
b[0-6]='\0' and b[7]=(soh)
I have told you how to do that. Since there is only one content byte, you have no earthly use for a long long or an int 64 -- unless that is the particular method you wish to use to hold it. If that's the case, you shouldn't have stated that you want it in a string-class string (which is every bit as effective as a vector, in this case).

It is impossible to tell whether you don't know what you want, or whether you just can't express it adequately. I suggest you back up a couple of steps, rethink your requirements, express them clearly, and post the outcome here.
0
felisca's Avatar, Join Date: Dec 2006
Go4Expert Member
Ok, I see that I didn't explain myself well enought. Sorry, that is since my poor English
I will try again
First of all the example I gave - was only an example. In my case all 8 bytes could have a value.

I'm trying to write a function for MD5 hash function
http://en.wikipedia.org/wiki/MD5
as mentioned in wikipedia. I was in a trouble with last 64 bits. That is what my question was about.
That is why I have choosen double. Because I need 64 bits and all of them are usefull.
What can I do?

Thanks!
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
Despite the fact that there may not (yet) be an official long long type for C++, you can be sure that any reasonable compiler will support it by one name or another. That's what I would use, in unsigned form. I didn't read your link, and I don't know what you're trying to do, but a dollar to a doughnut says that an unsigned long long will fit the bill.

Your original post was essentially a detriment to getting your problem solved. SOH hasn't a damned thing to do with it, apparently, except to mistakenly imply byte-sized entities. Specifying 7 other byte-sized entities ('\0') was just more mud in the water. Since my crystal is in the shop for ball joints, you might consider, next time, that we can't read your mind.