write and Save data to File in C++ using FSTREAM
How to write and Save data to File in C++ using FSTREAM Header file
//////Add header file
#include <iostream>
#include <fstream>
using namespace std;
/////create main function
int main()
{
string name;
int pin;
cout<<"Name: ";
getline(cin,name);
cout<<"Pin: ";
cin>>pin;
/////create file with the name you want e.g. DATA.text
ofstream obj("DATA.text");
/////pass data to file through insertion operator
obj << name << pin;
}
/////file writing and saving is complete.
⚠⚠⚠⚠⚠⚠if the link is not correct please let me know by commenting here⚠⚠⚠⚠⚠⚠
Post a Comment