how to create a simple document file to drive D in harddisk

M

mohamed azaz

hi

I want to know how can I create a simple doc file to drive D in
Harddisk by using c++ code

please answer me Quickly

bye bye
 
V

Victor Bazarov

mohamed said:
I want to know how can I create a simple doc file to drive D in
Harddisk by using c++ code

This is system-specific. Many systems simply don't have "drive"
or "drive D" or "Harddisk". On the systems that do, you would
open a file stream for write and give it a name [of a file] that
doesn't exist, and that might cause the system to create a file
for you (which may happen only when you close that stream).

std::eek:fstream file("D:\\simple_doc_file");
file << "blah";
file.close();
please answer me Quickly

You could only talk in this manner when you're in the position
of power. Even then I wouldn't recommend it.

I hope you mean it.

V
 
M

Mike Wahler

mohamed azaz said:
hi

I want to know how can I create a simple doc file to drive D in
Harddisk by using c++ code

#include <fstream>

int main()
{
std::eek:fstream ofs("D:file.doc");
return 0;
}

-Mike
 
H

Hans Mull

Mike said:
#include <fstream>

int main()
{
std::eek:fstream ofs("D:file.doc");
return 0;
}

-Mike
Use D:\\file.txt, so its more secure that it is really opened

Kind regards, Hans
 
M

Mike Wahler

Why would specifying a root directory make the open more
likely to succeed?
Also, D:/file.txt will also work, yes, even in windows.

OP never said *where* on drive D.

-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top