create file with certain text
-
hello i have a simple problem that i need to solve. i need to create a file, programmaticaly, with certain text. I am not sure if you can use static const char, but this is why i am asking. If anybody knows how to do this please help I know i have to use CreateFile and WriteFile api but i need code that uses this -Ryan M.
-
hello i have a simple problem that i need to solve. i need to create a file, programmaticaly, with certain text. I am not sure if you can use static const char, but this is why i am asking. If anybody knows how to do this please help I know i have to use CreateFile and WriteFile api but i need code that uses this -Ryan M.
Ryan McDermott wrote: need to create a file, programmaticaly, with certain text Use WIN32 File I/O API functions
CreateFile
andWriteFile
for this purpose. Ryan McDermott wrote: I am not sure if you can use static const char Yes you can. Gurmeet S. Kochar
If you believe in God, it's because of the Devil
My CodeProject Articles: HTML Reader C++ Class Library, Numeric Edit Control
-
hello i have a simple problem that i need to solve. i need to create a file, programmaticaly, with certain text. I am not sure if you can use static const char, but this is why i am asking. If anybody knows how to do this please help I know i have to use CreateFile and WriteFile api but i need code that uses this -Ryan M.
#include <iostream>
#include <fstream>bool WriteTheFile ()
{
std::ofstream ofs ( "MyFile.txt" ) ;
if ( !ofs )
return false ;
ofs << "My file contains this text" ;
return true ;
}Since the data is copied out to the file any text that is valid at the time of the write (in this case the '<<') can be written. IMO if you're writing in C++ then it's worth becoming familiar with the iostream part of the Standard Libary and reserving direct use of the Win32 API for special cases where you really need something non-standard. Paul