Click here to Skip to main content
15,923,006 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: BitmapButton Pin
Big Art13-Apr-03 7:45
Big Art13-Apr-03 7:45 
Question:confused::confused:How to create a vertical CTabCtrl control?? Pin
psusong11-Apr-03 7:52
psusong11-Apr-03 7:52 
AnswerRe: :confused::confused:How to create a vertical CTabCtrl control?? Pin
Ravi Bhavnani11-Apr-03 9:38
professionalRavi Bhavnani11-Apr-03 9:38 
GeneralRe: :confused::confused:How to create a vertical CTabCtrl control?? Pin
psusong11-Apr-03 11:47
psusong11-Apr-03 11:47 
GeneralFont Coloring Preview Pin
Jonah Bishop11-Apr-03 6:56
Jonah Bishop11-Apr-03 6:56 
GeneralRe: Font Coloring Preview Pin
Ravi Bhavnani11-Apr-03 7:06
professionalRavi Bhavnani11-Apr-03 7:06 
GeneralRe: Font Coloring Preview Pin
Jonah Bishop11-Apr-03 7:40
Jonah Bishop11-Apr-03 7:40 
GeneralC++ tokenizer Pin
naja11-Apr-03 6:05
naja11-Apr-03 6:05 
I really need your help guys because I am new to C++ and I don't understand many things.
I want to make a program that reads text files, tokenize the text and print the word frequency (how many same tokens exist in a file).
I have already started the program but now I got stuck.

I have this function which counts the frequency of a word in a file ("out.txt").This file has the tokens, one at each line. (The input text has alreadu been tokenized.) The function is called from main() when I want to count the word occurences of a file. When I call this function again (the file "out.txt" has changed,it has the tokens of the second file) because I want to count the frequency of words in another file, I get the total frequency of words(including the tokens of the previous file)in the file "1.txt".What I do wrong? Is there something happening with the iterator or the const? I really don't know a lot about these things. Here is the functions:

map<string,int> histogram;

void record(const string& s)
{
histogram[s]++;
}

void print(pair<const string,int=""> & r)
{
ofstream fout("eksodos.txt",ios::app);
fout << r.first << ' ' << r.second << '\n';
}

void freq()
{
ifstream fin("out.txt");
istream_iterator<string> ii(fin);
istream_iterator<string> eos;
for_each(ii,eos,record);
for_each(histogram.begin(),histogram.end(),print);

ifstream from("eksodos.txt");
ofstream to("1.txt");
char ch;
while(from.get(ch)) to.put(ch);
ofstream fout("eksodos.txt",ios::trunc);}

Thank you very much in advance
GeneralRe: C++ tokenizer Pin
Toni7811-Apr-03 22:50
Toni7811-Apr-03 22:50 
QuestionHow can I get the IP of my server? Pin
Salvador Dali11-Apr-03 5:17
Salvador Dali11-Apr-03 5:17 
AnswerRe: How can I get the IP of my server? Pin
Peter Weyzen11-Apr-03 6:35
Peter Weyzen11-Apr-03 6:35 
GeneralRe: How can I get the IP of my server? Pin
Salvador Dali11-Apr-03 7:17
Salvador Dali11-Apr-03 7:17 
GeneralRe: How can I get the IP of my server? Pin
Peter Weyzen11-Apr-03 7:28
Peter Weyzen11-Apr-03 7:28 
GeneralRe: How can I get the IP of my server? Pin
Salvador Dali11-Apr-03 22:42
Salvador Dali11-Apr-03 22:42 
GeneralMulti-dimensional Arrays Pin
ed111-Apr-03 4:44
ed111-Apr-03 4:44 
GeneralRe: Multi-dimensional Arrays Pin
valikac11-Apr-03 4:50
valikac11-Apr-03 4:50 
GeneralRe: Multi-dimensional Arrays Pin
Martyn Pearson11-Apr-03 5:31
Martyn Pearson11-Apr-03 5:31 
GeneralRe: Multi-dimensional Arrays Pin
ed111-Apr-03 5:58
ed111-Apr-03 5:58 
GeneralRe: Multi-dimensional Arrays Pin
jmkhael11-Apr-03 13:54
jmkhael11-Apr-03 13:54 
GeneralRe: Multi-dimensional Arrays Pin
ed114-Apr-03 3:09
ed114-Apr-03 3:09 
GeneralGetting the Bitmap of a font using GDI andMFC Pin
cod3r11-Apr-03 2:28
cod3r11-Apr-03 2:28 
Generalsyslistview32 Pin
_crs_11-Apr-03 2:23
_crs_11-Apr-03 2:23 
GeneralRe: syslistview32 Pin
cubiq11-Apr-03 11:07
cubiq11-Apr-03 11:07 
GeneralVC++ 6.0/ATL/COM Pin
Duncan Wells11-Apr-03 1:58
Duncan Wells11-Apr-03 1:58 
GeneralRe: VC++ 6.0/ATL/COM Pin
Zdeslav Vojkovic11-Apr-03 2:32
Zdeslav Vojkovic11-Apr-03 2:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.