Two possibilities:
create.open("C:\\Service Hub\\Names.dat", ios::out); :
\\ wil be interpreted as a single \
or (prefered)
create.open("C:/Service Hub/Names.dat", ios::out); :
Use forward slash.
Although windows is using the backslash as directory separator, in all C and
C++ functions you can also use
the forward slash. In this way you can also write compatible code with
normal operating systems.
-----Original Message-----
From: Dondolo Mpho [mailto:MDo...@OL...]
Sent: Friday, January 03, 2003 09:25 AM
To: 'dev...@li...'
Subject: [Dev-C++] UNKNOWN ESCAPE SEQUENCE
Hi all,
I am trying to write to a file in my disk by putting in the complete
pathname in the filename parameter, as my books suggest ,
----------------------------------------------------------------------------
--------------------
#include<fstream.h>
ofstream create; //declaring a file stream for writing
main()
{
create.open("C:\Service Hub\Names.dat", ios::out);
/************************************************
/*******************************************
Here I get errors unknown escape
sequences \S and \N.
How can I tell C++ that that is a part and not an escape sequence?
*************************************/
create<<"Mpho Dondolo\n";
create<<"Lindeka Dondolo\n";
create<<"Limpho Dondolo\n";
create.close();
return 0;
}
|