|
From: James G. <Jam...@Cl...> - 2000-11-15 08:22:36
|
This code is just the bare bones and should do more error checking etc.
In 'C' try:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE* outfile;
char fname[] = "myfile.txt";
if((outfile = fopen(fname, "w")) == NULL)
{
perror(fname);
exit(1);
}
fprintf(outfile, "This text should now be in your file.\n");
fclose(outfile);
return 0;
}
In C++ try:
#include <stdio.h>
#include <fstream>
using namespace std;
int main(int argc, char *argv[])
{
fstream mystream;
char fname[] = "myfile.txt";
mystream.open(fname, ios::out);
mystream << "This text should now be in your file." << endl;
mystream.close();
return 0;
}
Regards,
James.
-----Original Message-----
From: Shiva Kissoon [mailto:shi...@ho...]
Sent: Tuesday, November 14, 2000 10:46 PM
To: dev...@li...
Subject: [Dev-C++] output to a text
How do i write my output to a text file?
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
http://lists.sourceforge.net/mailman/listinfo/dev-cpp-users
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
This electronic message and any attachment is intended to be
read by the named addressee(s) only.
Any other recipient should be aware that its contents may be
legally privileged and/or confidential and that its use,
disclosure, copying or distribution may be unlawful.
Unless you are a named addressee, please delete this message
Whilst C. & J. Clark International Limited has taken steps
to prevent the transmission of computer viruses with electronic mail,
responsibility for screening incoming messages and the risk of such
transmission and its consequences lies with the recipient.
C. & J. Clark International Limited
Registered in England and Wales
Company No. 141015
Registered Office: 40 High Street, Street, Somerset BA16 0YA
Telephone: +44 (0) 1458 443131
Fax: +44 (0) 1458 447547
|