2011-03-21 66 views
1

我有一个文件处理问题。我正在写的文件处理代码,看起来像这样:文件处理编译错误

ofstream SaveFile("/home/core-site2.xml") 

//SaveFile<<"<?xml version="1.0"?>" ; 
SaveFile <<endl ; 
SaveFile<<"<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>" ; 

当我编译这个文件我得到以下错误:

error: expected ‘;’ before ‘text’

什么shouuld我做删除错误? 如何正确写入这些行?

+0

检查您是否错过了将分号(;)放在前一行或不放。并回复评论。你能否更正确地格式化问题? – 2011-03-21 09:26:39

回答

2

SAVEFILE的声明错过一个尾随 ';'。此外,你需要逃避字符串中的引号:

SaveFile<<"<?xml-stylesheet type=\"text/xsl\" href=\"configuration.xsl\"?>" ; 
+0

这解决了我的问题 – user513164 2011-03-24 08:48:56

1
ofstream SaveFile("/home/core-site2.xml") 

此行缺少分号。

1

你在你的ofstream声明结尾缺少一个分号。

2
ofstream SaveFile("/home/core-site2.xml"); 

SaveFile<<"<?xml-stylesheet type=\"text/xsl\" href=\"configuration.xsl\"?>" ; 
+0

thanx为您解答我的问题的答案 – user513164 2011-03-22 05:17:01

1

SaveFile<<"<?xml-stylesheet type=\"text/xsl\" href=\"configuration.xsl\"?>" ;

你需要逃避字符串中的引号。否则,编译器认为它们是字符串的结尾。