What's wrong !! I try to run this code but still showing me this in the compile :-( #include #include #include #include using namespace std; template void printmap(map < KTy, Ty >&map){ typename std:: map::iterator iterator; for(iterator p=map.begin();p!=map.end();p++){ cout << p->first<<":" <sceond< wordscount; { ifstream filestream(fileName); if(filestream.is_open()){ while (filestream.good()){ string word; filestream>> word; if(wordscount.find(word)==wordscount.end()){ wordscount[word]=1; } else{ wordscount[word]++; } } } else{ cerr << "Can't open the given file."<
What's wrong !!
I try to run this code but still showing me this in the compile :-(
#include<iostream>
#include<map>
#include<string>
#include<fstream>
using namespace std;
template <class KTy,class Ty>
void printmap(map < KTy, Ty >&map){
typename std:: map<KTy,Ty>::iterator iterator;
for(iterator p=map.begin();p!=map.end();p++){
cout << p->first<<":" <<p->sceond<<endl;
}
}
int main(void){
static const char* fileName="hitchhikersguide.txt";
map<string , unsigned int > wordscount;
{
ifstream filestream(fileName);
if(filestream.is_open()){
while (filestream.good()){
string word;
filestream>> word;
if(wordscount.find(word)==wordscount.end()){
wordscount[word]=1;
}
else{
wordscount[word]++;
}
}
}
else{
cerr << "Can't open the given file."<<endl;
return EXIT_FAILURE;
}
printmap(wordscount);
}
return EXIT_SUCCESS;
}
![64
|ubuntu [Running] - Oracle VM VirtualBox
File
Machine
View
Input
Devices
Help
Activities
Visual Studio Code
Dec 14 18:00 •
SV
Labb4.cpp - labb4 - Visual Studio Code
File Edit Selection View Go Run Terminal Help
PROBLEMS
OUTPUT
DEBUG CONSOLE TERMINAL
1: Code
+ 띠
arwakhaddour@osboxes:~/Documents/C++/labb4/L4_wc$ cd "/home/arwakhaddour/Documents/C++/labb4/L4 _wc
/" && g++ Labb4.cpp -o Labb4 && "/home/arwakhaddour/Documents/C++/labb4/L4_wc/"Labb4
Labb4.cpp: In function 'void printmap(std::map<KTy, Ty>&)':
Labb4.cpp:9:17: error: expected ';' before 'p'
9 |
v L4_wc
E hitchhikersguide.txt
E labb4
C• labb4.cpp
for(iterator p=map.begin();p!=map.end();p++){
G• Labb4.cpp
C• tempCodeRunnerFi...
e wc.pdf
Labb4.cpp:9:32: error: 'p' was not declared in this scope
for(iterator p=map.begin();p!=map.end();p++){
9
L4_wc.zip
arwakhaddour@osboxes:~/Documents/C++/labb4/L4_wc$ I
O 0 A0 6
Live Share -- INSERT --
Ln 33, Col 33 Spaces: 4 UTF-8 LF C++ Linux 1012 B 7 Q](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F359a1891-a6e6-42ff-9fa2-e97930deb46b%2F4300928a-f440-4daf-b126-414777c56bdc%2Fxh1rjpq_processed.png&w=3840&q=75)

Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images









