Reads information from the file and outputs it onto the screen
2012-08-10 17:46
495 查看
#include <fstream> #include <iostream> using namespace std; int main () { char data[80]; ofstream outfile; outfile.open("file.dat"); cout << "Writing to the file" << endl; cout << "Enter your name: "; cin.getline(data, 80); outfile << data << endl; cout << "Enter your id: "; cin >> data; cin.ignore(); outfile << data << endl; outfile.close(); ifstream infile; cout << "Reading from the file" << endl; infile.open("file.dat"); infile >> data; cout << data << endl; infile >> data; cout << data << endl; infile.close(); return 0; }
相关文章推荐
- [20160731]read a file and print it on the screen
- Resolution to the record count increasing of the file exported from DB when ‘0A’ is included in it
- The type java.lang.Object cannot be resolved.It is indirectly referenced from required .class file
- eclipse无法加载Layout(Eclipse is loading framework information and the layout library from the SDK fold)
- Truncated class file description The server encountered aninternal error that prevented it from fulf
- The type java.lang.Object cannot be resolved.It is indirectly referenced from required .class file
- Error reading from file ... .msi Verify that the file exists and that you ...
- A class file was not written. The project may be inconsistent, if so try refreshing this project and building it. eclipse提示错误
- Resolution to the record count increasing of the file exported from DB when ‘0A’ is included in it
- Entering the kernel without a driver and getting interrupt information from APIC
- a survey about how to make a file dynamically and offer it to download,but still not save the file!
- The information exchange between MES and other IT solutions
- 发布应用到App Store问题:The CodeResources file is missing and it must be a symbolic link to _CodeSignature
- Entering the kernel without a driver and getting interrupt information from APIC
- Git: untrack a file in local repo only and keep it in the remote repo
- A class file was not written. The project may be inconsistent, if so try refreshing this project and building it
- [Unity问题]The file "MemoryStream" is corrupted! Remove it and launch unity again!
- This tip shows how to extract the width and height from a bitmap source file on disk.
- After press print button, it will displays Print To File; and the progress always 0%
- Database 'xxx' cannot be upgraded because it is read-only or has read-only file Make the database or files writeable, and rerun recovery.