|
Read MSDN article Q138681.
|
|
|
|
|
Hi All,
I Need Help Regarding The Storing of Data in ASCII format
How To store TEXT Data in ASCII Format and In which Format
Ascii Data to be Stored
and What are The Precautions to Be Taken Storing The Data
In ASCII Format.
Thanks In Advance
|
|
|
|
|
|
One down side to storing data in plain ASCII is that it's readable using a simple text editor like Notepad.
Another limitation is that you're limited to the ASCII set of characters, which means if you want to store binary data, you'll need to convert it to ASCII (which causes a 2x increase in size) before storing it.
If you're looking for a general article on serializing data, you might find this set[^] of articles helpful.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Check out CStdioFile, it will do what you want.
Also you can use regular C++ iostreams (e.g., ifstream and ofstream) to be more "standard" or if you aren't using MFC. MSDN has docs for all of these.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
Does anyone know if there is a STL algo to remove duplicate items in a vector?
I have a vector of string values that I would like to make unique. The vector will eventually be sorted. Is there a quick stl way of doing this?
On a similar not, I tried using std::set to filter duplicate strings, but I found this to be extremely slow.
I Dream of Absolute Zero
|
|
|
|
|
There is no faster way of doing this because if you think about it you have to check the string does not exist yet. Set is pretty much the fastest way of doing that unless you want to use a hash table. Yes, there is a hash table in some versions of the stl.
If you say the vector will then be sorted, you were right to use set in the first place.
|
|
|
|
|
cheers for that, dude.
I Dream of Absolute Zero
|
|
|
|
|
Is this the type of thing you want? Especially if sorting may be required
sort(source.begin(),source.end());
unique_copy(source.begin(),source.end(),back_inserter(dest));
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Can't you check for duplicates as the items are added?
|
|
|
|
|
DavidCrow wrote:
Can't you check for duplicates as the items are added?
Thats why I was using the std::set as it only allows unique entries, but it was very slow on the insertions.
Having read the above replies, I may not have a choice on the performance and may have to stick with a set instead of buffering in a vector and then removing dups.
I Dream of Absolute Zero
|
|
|
|
|
That is what set does, except it does it in an efficient way.
|
|
|
|
|
RChin wrote:
On a similar not, I tried using std::set to filter duplicate strings, but I found this to be extremely slow.
You may find that using std::hash_set instead of std::set will be faster for storing strings, provided you have a good hash function.
- Mike
|
|
|
|
|
Thanks for the tip Michael
I Dream of Absolute Zero
|
|
|
|
|
Hi.
Have a simple class for which I want to define a << operator
to put some ints on an ostream. Something like this worked
FINE yesterday, before I just renamed my simple class:
<br />
ostream& operator<<(ostream& os, const TimMinSek& t) {<br />
return os << t.tms[TIM] << ':' << t.tms[MIN] << ':' << t.tms[SEK];<br />
}<br />
The t.tms-stuff are the ints from inside my class obviously.
I did:
<br />
#include <ios><br />
using std::ostream;<br />
in the .h-file for this operator function (and I also include it in its .cpp-file), so I can refer to ostreams just fine. The error I get is:
<br />
no operator "<<" matches these operands<br />
operand types are: std::ostream << const int<br />
return os << t.tms[TIM] << ':' << t.tms[MIN] << ':' << t.tms[SEK];<br />
----------^<br />
but it doesn't matter what else i try to feed the ostream& os,
all I can return seems to be 'os' itself! I can't feed chars
to it either, and definately not my precious ints
Ironically, I more or less copied this function from section
21.2.3 in my edition of Bjarne Stroustrup's 'The C++ language'
and I can't tell the difference between his and mine (and besides
mine worked earlier as I said). Puzzling!
Thanks for any help
regards
/Petter
|
|
|
|
|
Hello Guys,
Can anybody of you can give me some ideas or links or code about how to convert .pdf file into .txt file.
Lot of readymade applications are available on net. I don't interested in all those but I want to make my own application for conversation.
Thanking You
C.R.Naik
|
|
|
|
|
You'll need to use the PDF SDK.
|
|
|
|
|
Friends,
Suppose we pass an object of a certain class as a reference to two other classes. It means that the two classes have a "same" copy of an object. This is a type of "composition"
Now insted of "composition", i want to get the same effect using "inheritance" OR i want my derived classes to inherit from "same" base class. Same base class means that the same base subobject. If one class make any change in the data of its parent, then the change should get reflected in the second class as its parent is same as that of first class.
How is it possible ???
|
|
|
|
|
What do you actually want to do? Are you a student quoting from your exercise or something?
You should rephrase your question so it actually makes sense.
|
|
|
|
|
Consider the following code:
class Parent
{
public:
SetValue(int a)
{
m_value = a;
}
private:
int m_value
};
class Brother:public Parent
{
brother()
{
SetValue(12)
{
};
class Sister:public Parent
{
Sister()
{
SetValue(8)
}
};
As can be seen above, the two classes "Brother" and "Sister" are derived from the same base class "Parent" Both the children classes have their own copy of "Parent". If the class "Brother" makes any change in the data member of "Parent", then the change will not effect the "Parent" of "Sister" as "Sister" has its own "Parent"
What i want is that, both the children classes should share the "same" parent. And if "Brother" changes the data present in its "Parent", then the data of the "Parent" of "Sister" should also gets changed automatically as both "Brother" and "Sister" will have same subobject "Parent".
How can i achieve this goal.
|
|
|
|
|
Jamal Jamshed wrote:
How can i achieve this goal.
static int m_value;
|
|
|
|
|
|
1) Create a base class that all related classes are derived from.
2) Make any member variables that you wish to be common to all derived classes static members.
3) If you are going to destroy (free) any of the members in the destuctor then you need to add a static reference counter member variable that is incremented in the constructor and decremented in the destructor.
class MyClass
{
static int m_nRefCount;
static int m_nMem1;
static whatever* m_pWhatEver;
...................
public:
...................
};
int MyClass::m_nRefCount = 0;
whatever MyClass::m_pWhatEver = NULL;
MyClass::MyClass()
{
++m_nRefCount;
}
MyClass::~MyClass()
{
if( --m_nRefCount < 1 )
{
if( m_pWhatEver is valid )
delete m_pWhatEver;
}
}
:-DHave a wonderful day.
INTP
|
|
|
|
|
hi..
everytime i start my program (and shut it down afterwards) VS reports two memory leaks.
i've tried the _crtBreakAlloc - technique (Q151585) to spot it.. but the problem is, that the allocation might occur, before i have got a chance to type in the number (i use "step into" to step into the code).. because it doesn't break at this numbers, but when i quit the program, the leaks occur.
is there any other possibility to stop at the allocation, which causes the problem ?(the "double click on line thingie" doesn't work too)
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
how can i use m_Combo.SetItemDataPtr for Combo Box to display each entered number in Edit control.??
I have a Edit Control field to enter variable Numbers and a Combo box from 1 to 10, every Index in Combo Box has to have a certain changed Edit Control Number.
Best reguards!
|
|
|
|