|
You need to read line by line on the text files.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
You could try this:
std::ifstream myFile("a.cpp");
int count = 0;
std::string s;
while (std::getline(myFile, s))
++count;
although I suspect this (counting the line-feed characters in the file) is slightly better:
std::ifstream myFile("a.cpp", std::ios::binary);
myFile >> std::noskipws;
std::cout << 1+std::count(std::istream_iterator<char>(myFile), std::istream_iterator<char>(), (char)10) << std::endl;
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
hallo to all,
i have an SDI-MFC application which is divided by a CSplitterWnd object to 2 parts, the upper part for input text and the lower part for the output text, i need to be able to print out the content of both parts individually. I treid to use the OnPrint() and OnPrintFile(), but both are protected members. Any help to solve this problem will be appriciated. Please explain or give a link to a site that explain in details. Thanks.
|
|
|
|
|
Since you have two CView -derived classes, and OnPrint() is a virtual function, you should be able to override it in each view.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I have CEditView and OnPrint() is a protected member, i did not understand what dii you mean?
|
|
|
|
|
susanne1 wrote: I have CEditView...
Derive a class from it rather than use it directly.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
after driving a class from CEditView , i will define the protected OnPrint(CDC* pDc, CPrintInfo* pInfo)
as void OnMyPrint(CDC* pDc, CPrintInfo* pInfo)
{
which code comes hier?
}
|
|
|
|
|
susanne1 wrote: which code comes hier?
What ever you need to print the contents of that view. There's no one-answer solution.
As a test to make sure you're on the right track, you could do something like:
void CEditView1::OnPrint(CDC* pDc, CPrintInfo* pInfo)
{
pDC->TextOut(5, 5, "This text is from CEditView1", 28);
}
void CEditView2::OnPrint(CDC* pDc, CPrintInfo* pInfo)
{
pDC->TextOut(5, 5, "This text is from CEditView2", 28);
}
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
|
It will be my second time to design a website. Last time I use C# and ASP.net all I do in my teem is writing event manipulation C# code begind every important component(such as buttons, textbox, etc..). I know little a bout what happens after a user send a get message( which looks like: GET www.dodd.com/dkdlf.html HTTP 1.1/r/n.....) and how this data is transfered and maninulated by what? What's the relationship between Server II and C#code and ASP.net code. I really don't know nothing about this and I need a book that can at least demonstrate these things in a clear way.
Can someone provide a book fulled my demands?
It will be greatly appreciated because I really want to make myself clear at what i'm doing.
Thanks!
Jack
|
|
|
|
|
I have a book about Beginnig ASP.NET 3.5 in C# 2008 (Second Edition Matthew MacDonald)
I write for you list of its chapters:
Part 1 Introducing .NET
Part 2 Developing ASP.NET Applications
PART 3 Building Better Web Forms(Validation,Rich Controls,User Controls and Graphics,Styles, Themes, and Master Pages,Website Navigation)
PART 4 Working with Data
PART 5 Website Security
PART 6 Advanced ASP.NET
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Thanks, obvious it's no my cup of tee.
btw, i have another book <high permance="" web="" site=""> that was publiched by O'lley, is extreme good.
But i need a full view of designing and publicizing of a web site.
Thanks, though.
|
|
|
|
|
BTW does your previous problem solve?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
if you are referring the Heap Management problem yes
if "CRT runtime error, must terminate the application" then no, alas.
|
|
|
|
|
JackPuppy wrote: C# and ASP.net
And so you asked in the C++/MFC message board. Good move, Einstein. Why didn't you try the correct one[^]?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi, I have problems whith the BOOST <unordered_map> container.
GetMessageFunctorHashMap() returns an unordered_map<string,Functor*>.
Then I try to insert a new item. The operation seems to be OK but when I request if the container is empty i allways recieve TRUE.
Can anyone helps me, please?
GetMessageFunctorHashMap()["Hello"]=(Functor*) new SpecificVoidFunctor<messagesystem>(this, &MessageSystem::Exit);</messagesystem>
GetMessageFunctorHashMap().empty(); returns 1
Thanks!
|
|
|
|
|
If the result type of GetMessageFunctorHashMap is unordered_map<string,Functor*> , then your first line of code modifies a COPY of your unordered_map ...which is then discarded, because it goes out of scope.
To modify the unordered_map that GetMessageFunctorHashMap references, the return type needs to be a reference to unordered_map<string,Functor*> , i.e. unordered_map<string,Functor*>&
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
You are right! Thanks!
Now the code crashes in the string library when internally the Unordered_Map container tries to compare two strings. Anyone knows if unordered_map can compare and hash strings by default? Or i have to define the hash function and the compare function?
Thanks!
|
|
|
|
|
It won't hash the strings - you use hash_map for that (although in my experience, std::map has better performance).
But it will compare strings properly - I guess it'll use operator< ?
BTW - this code worked fine on g++ 4.0.1 (using Boost's TR1 implementation) and on VS2008 (using its own TR1):
#include <string>
#include <iostream>
#include <unordered_map>
int _tmain(int argc, _TCHAR* argv[])
{
std::tr1::unordered_map<std::string, int> a;
a.insert(std::make_pair("Hello", 10));
a.insert(std::make_pair("Goodbye", 20));
std::cout << a.count("test") << std::endl;
std::cout << a.count("Hello") << std::endl;
return 0;
}
This does comparisons...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks!
Finally I used a simple std::map<string,>, works OK and it's fine for the first version of my system. But I still don't known why the unordered_map and the hash_map containers don't works....Well....that remain a mystery xD.
|
|
|
|
|
I have 20 names and there makes stored in a map. My requirement is to get hghest marks of top 10 studens.
please let me know the sorting algorithim to find that out.
Thanks in Advance
|
|
|
|
|
find out how value_compare(), it will compare the values that way you will know which key comes first
|
|
|
|
|
|
You may try to implement yourself a simple sorting algorithm, like, for instance [^], it maybe an interesting experience.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
If you used this:
std::map<MarkType, NameType> marksAndStudents;
(where MarkType is the type you use for a students marks and NameType is the type you use for a students name, then *rbegin() points at the student with the highest mark - try this:
std::map<int, std::string> s;
s.insert(std::make_pair(10, "10"));
s.insert(std::make_pair(20, "20"));
s.insert(std::make_pair(30, "30"));
s.insert(std::make_pair(40, "40"));
s.insert(std::make_pair(50, "50"));
s.insert(std::make_pair(60, "60"));
s.insert(std::make_pair(70, "70"));
s.insert(std::make_pair(80, "80"));
s.insert(std::make_pair(90, "90"));
s.insert(std::make_pair(100, "100"));
s.insert(std::make_pair(110, "110"));
s.insert(std::make_pair(120, "120"));
std::map<int, std::string>::const_reverse_iterator it = s.rbegin();
for (int i=0;i<10;++i)
{
std::cout << it->second << std::endl;++it;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|