| | |
endline
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
Can i also point out that those are C functions. If your after the C++ solution it goes something like this
Chris
C++ Syntax (Toggle Plain Text)
#include <ofstream> #include <iostream> using namespace std; int main(void){ ofstream out_file; out_file.open("example.txt"); if(out_file.is_good()){ out_file << "\nHello, World"; out_file.close(); }else{ cout << "Error Opening File"; cin.get(); } return 0; }
Chris
Knowledge is power -- But experience is everything
The 1st printf in the original post (
Apropos,
makes ill-formed text file where the last line is not terminated by line separator...
fprintf(txtFile, "%s", "\n"); ) should work too. The simplest way in C style is fputc('\n',txtFile) .Apropos,
C++ Syntax (Toggle Plain Text)
out_file << "\nHello, World"; out_file.close();
Last edited by ArkM; Nov 7th, 2008 at 1:21 pm.
Allow me to correct my error
C++ Syntax (Toggle Plain Text)
out_file << "\nHello, World\n"; out_file.close();
Knowledge is power -- But experience is everything
![]() |
Similar Threads
- how to print the following series (C)
- reading names into char array of pointers (C++)
- 1 - one 100-one hundred (C++)
- Web Form (HTML and CSS)
- Beginner working with tab-delimited text file (Perl)
- making labels with c++ (C++)
- Help complete typical question with for loops (C++)
Other Threads in the C++ Forum
- Previous Thread: Trouble compiling static-linking library
- Next Thread: hellow
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion count data database delete deploy desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game getline google graph homeworkhelp homeworkhelper iamthwee ifstream input int integer lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






