cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
text file output - or it would be if com
text file output - or it would be if comp wasnt being stubborn
Apr 23, 2012 at 9:40am UTC
equitime77
(3)
can you tell me why I am not getting any output to a text file? I cant see why its not doing it.
void __fastcall TmainForm::Save1Click(TObject *Sender)
{
/* if (SavePic->Execute ())
{*/
FILE* outfile = NULL;
outfile = fopen ("c:\123\etext.txt", "w");
if (outfile == NULL) ShowMessage ("Error opening file");
else
{
ShowMessage ("File found, comp being pathetic");
fprintf (outfile, "999\n");
}
fclose (outfile);
}
thanks
Apr 23, 2012 at 9:47am UTC
Peter87
(11254)
\ is used for escape characters like \n. If you want backslash you have to write \\. It is also possible to use forward slashes in file paths.
"c:\\123\\etext.txt"
"c:/123/etext.txt"
Apr 23, 2012 at 12:02pm UTC
equitime77
(3)
thanks :)
Topic archived. No new replies allowed.