开发者

File handling compilation error

开发者 https://www.devze.com 2023-02-18 06:28 出处:网络
I have a problem with file handling.I\'m writing code for file handling, that looks like this: ofstream SaveFile(\"/home/core-site2.xml\")

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号