I have a problem with file handling. I'm writing code for file handling, that looks like this:
ofstream SaveFile("/home/core-site2.xml")
//SaveFile<<"<?xml version="1.0"?>" ;
SaveFile <<endl ;
SaveFile<<"<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>" ;
When I compile this file I get the follow开发者_开发问答ing error:
error: expected ‘;’ before ‘text’
What shouuld I do to remove the error? How do I write these line properly?
The declaration of SaveFile misses a trailing ';'. Also, you need to escape the quotes inside the string:
SaveFile<<"<?xml-stylesheet type=\"text/xsl\" href=\"configuration.xsl\"?>" ;
ofstream SaveFile("/home/core-site2.xml");
and
SaveFile<<"<?xml-stylesheet type=\"text/xsl\" href=\"configuration.xsl\"?>" ;
ofstream SaveFile("/home/core-site2.xml")
This line lacks a semicolon.
You're missing a semi-colon from the end of your ofstream declaration.
SaveFile<<"<?xml-stylesheet type=\"text/xsl\" href=\"configuration.xsl\"?>" ;
You need to escape the quotes in the string. Otherwise the compiler thinks they are the end of the string.
精彩评论