Hello!
I need code for creating a file in C++
Please help!
Hello!
I need code for creating a file in C++
Please help!
Hello Rupali!
You need to study these concepts!
http://www.codersource.net/cpp_file_io.html
Code:#include <iostream> #include <fstream> int main() { std::ofstream o("Hello.txt"); o << "Hello, World\n" << std::endl; return 0; }
To create a new file, open an existing file, or save a file, you use the fopen() function. Its syntax is:
FILE *fopen(const char *FileName, const char *Mode);
The first argument, FileName, must be a valid name of a file. If the user is creating or saving a new file, you can let him specify the name of the file, following the rules of the operating system. If the user is opening an existing file, you can make sure the file really exists, retrieve its name and pass it to the fopen() function.
Because the fopen() function is used to save a new file, to open an existing one, or to save a file that was only modified, the second argument, Mode, actually allows you to decide what operation the function will be used to perform.
Bookmarks