| | |
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
Views: 893 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment based beginner binary c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multidimensional multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






