user513164
user513164

Reputation: 1858

File handling compilation error

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 following error:

error: expected ‘;’ before ‘text’

What shouuld I do to remove the error? How do I write these line properly?

Upvotes: 1

Views: 155

Answers (5)

Nathan
Nathan

Reputation: 11149

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.

Upvotes: 1

jeroenh
jeroenh

Reputation: 26772

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\"?>" ;

Upvotes: 2

Oleg Svechkarenko
Oleg Svechkarenko

Reputation: 2516

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

and

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

Upvotes: 2

forsvarir
forsvarir

Reputation: 10839

You're missing a semi-colon from the end of your ofstream declaration.

Upvotes: 1

Bj&#246;rn Pollex
Bj&#246;rn Pollex

Reputation: 76778

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

This line lacks a semicolon.

Upvotes: 1

Related Questions