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."<

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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
Transcribed Image Text: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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education