473,608 Members | 2,054 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I am learning c++ from c++ Primer( Fourth edition). I am writing a program on page

5 New Member
371 of this book .
# include<iostrea m>
#include<map>
#include<string >
#include <ios>
#include <stdexcept>
using namespace std;
int main(int argc,char **argv)
{
string map_file,open_f ile;
map<string,stri ng>trans_map;
string key,value;
if(argc != 3)
throw runtime_error ("wrong no. of argument")
ifstream map_file;
if(!open_file(m ap_file[1]))
throw runtime_error(" no transformation file");
while (map_file>> key>>value)
trans_map.inser t(make_pair(key ,value));
ifstream input;
if (!open_file(inp ut,argv[2]));
throw runtime_error(" no input file");
string line;
while(getline(i nput,line))
{
istringstream stream(line);
string word;
bool firstword=true;
while (stream>>word)
{
map<string,stri ng>::const_iter ator map_it =trans_map.find (word);
if(map_it !=trans_map.end ())
word =map_it->second;
if (firstword)
firstword = false;
else
cout <<" ";
} cout<<endl;
}
return 0;
}
I am getting an errors :
/home/ankit/wordtransfer.cc ||In function ‘int main(int, char**)’:|
/home/ankit/wordtransfer.cc |14|error: expected `;' before ‘ifstream’|
/home/ankit/wordtransfer.cc |15|error: no match for call to ‘(std::string) (char&)’|
/home/ankit/wordtransfer.cc |17|error: no match for ‘operator>>’ in ‘map_file >> key’|
/home/ankit/wordtransfer.cc |19|error: aggregate ‘std::ifstream input’ has incomplete type and cannot be defined|
/home/ankit/wordtransfer.cc |25|error: variable ‘std::istringst ream stream’ has initializer but incomplete type|
||=== Build finished: 5 errors, 0 warnings ===|

can anyone please help???
Aug 7 '09 #1
1 2902
mac11
256 Contributor
I can help a little. First, the compiler is telling you what's wrong, so believe it.

For instance, on line #14
Expand|Select|Wrap|Line Numbers
  1. throw runtime_error ("wrong no. of argument")
you need a semicolon on the end of that line.

line #15
Expand|Select|Wrap|Line Numbers
  1. if(!open_file(map_file[1]))
I don't know what you're trying to do and the compiler doesn't either. What is that line supposed to actually do? Are you trying to initialize a string or open a file?

Also you have two variables both named map_file, one a string and one a ifstream.
Aug 7 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2455
by: Darrell | last post by:
Greetings, I wish to purchase Visual Basic (5 or 6) with cost being a major factor. In perusing eBay, I find that there are at least 3 versions of each. I would like to know the differences between the Learning edition, the Professional edition and the Enterprise edition. Thanks in advance for your consideration.
4
7619
by: neil f | last post by:
I'm thinking of investing in a copy of VB6 and was going to go for the Learning Edition (maybe Deluxe). Now I've seen a comment that the Learning Edition does not create .exe files. I presume that means the programs I create will only be able to run inside the editor's environment. So if I progress to producing small programs suitable for sharing (say from a website), will I then have to upgrade to the Pro version? In other words, should I...
0
936
by: j_a_s_p_e_r | last post by:
Hi I just got the Deluxe Learning Edition and VC# .NET Standard does not have a lot of the project types. I was disappointed that I couldn't actually do a lot of the projects in the Step by Step book. I felt ripped off. Anyway I found that you can copy the Console Wizard and Project and modify the script to point to defaultDLL.csproj to make a DLL project. Does anyone know how I can get the other projects? Someone mentioned that you can...
3
1214
by: Grant Harmeyer | last post by:
Hi All: According to MSDN, C# Standard Edition is good for writing C# programs for Windows or the Web. I am an ASP.NET programmer, and I use both VB and C#. I am looking to doing some hobby programming (WebForms & a limited amount of WindowsForms) at home, and I can't justify fronting the cost for VS.NET 2003 (although I love the IDE and use it at work), can anyone describe to me what the major differences will be from VS.NET to C#...
1
1501
by: Matt S | last post by:
Does the liscense for the VC++.Net 2003 allow the user to purchase a downgrade to VC++.NET 2002? DO I need to buy a standard version of VC++.NET to downgrade? I need to get VC++ 2002, but I can't find it locally. Downgrading is an option, but if the DLE licesnse doen't allow me to downgrade I will have to keep looking for a standard version.
8
1516
by: mark | last post by:
I have just dug out my VB5 Deluxe Learning Edition manuals but I find that I've lost the CD with the VB5 Learning Edition on it. Does anyone know if there is anywhere that I can download it from? I'm currently an unemployed programmer and I am cross-training from another version of BASIC (PICK BASIC).
4
2053
by: Christian Blackburn | last post by:
Hi Gang, I saw this for sale online: Microsoft Visual Basic.NET Deluxe Learning Edition Version 2003. I'm wondering is the CD that's bundled with the learning edition just a digitized version of the book or is it an interactive tutorial? Thanks, Christian Blackburn
3
2532
by: huangshan | last post by:
hi all I read "C++ Primer, Fourth Edition" , but can't understand this sentence "By making the parameters const references, we allow types that do not allow copying." in "16.1. Template Definitions" . who can tell me? thanks
6
1515
by: =?Utf-8?B?cGNuZXJk?= | last post by:
I know that VB installs version 3.5 of .Net. I have versions 1.1 & 2.0 on my PC. Can I uninstall versions 1.1 & 2.0 after I install VB? I've been browsing thru books on VB Express Edition. In one book it stated that VB comes with a "classic" VB to VB.Net converter. In another book, I read that the converter comes with Visual Studio. Which is it? I know that ClickOnce can create an installer for a CD or DVD. Can it create an installer...
0
8087
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8493
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8179
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8365
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5499
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3993
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1620
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1363
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.