B
blackkettle
The code is as follows:
#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
main(int argc, char *argv[])
{
if(argc!=2)
{
cout<<"Usage:write <filename>\n";
return 1;
}
ofstream outf(argv[1]);
if(!outf)
{
cout<<"Cannot open output file.\n";
return 1;
}
cout<<"Write strings to disk, RETURN to stop\n";
char str[60];
do
{
cout<<":";
gets(str);
outf<<str<<endl;
}while(*str);
outf.close();
return 0;
}
After I compiled and built the code, a file named 714.exe was
generated.
In DOS, I input C>714 file and enter,
I thought the sentence "Write strings to disk, RETURN to stop" would
show up. However, it did not appear.
Only after I enter some sentences and enter twice would it come out.
I was wondering what is the problem.
Thank you very much!
#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
main(int argc, char *argv[])
{
if(argc!=2)
{
cout<<"Usage:write <filename>\n";
return 1;
}
ofstream outf(argv[1]);
if(!outf)
{
cout<<"Cannot open output file.\n";
return 1;
}
cout<<"Write strings to disk, RETURN to stop\n";
char str[60];
do
{
cout<<":";
gets(str);
outf<<str<<endl;
}while(*str);
outf.close();
return 0;
}
After I compiled and built the code, a file named 714.exe was
generated.
In DOS, I input C>714 file and enter,
I thought the sentence "Write strings to disk, RETURN to stop" would
show up. However, it did not appear.
Only after I enter some sentences and enter twice would it come out.
I was wondering what is the problem.
Thank you very much!