What is fstream in c++ code example
Example 1: fstream in c++
#include<fstream>
int main()
{
fstream file;
/*if we use fstream then we need to specify at least one
parameter mode like ios::out or ios::in else the file will not open */
file.open("filename.txt", ios::out|ios::in);
/*all work with file*/
file.close();
return 0;
}
Example 2: pionter in c++
#include <iostream>
using namespace std;
int main(){
//Pointer declaration
int *p, var=101;
//Assignment
p = &var;
cout<<"Address of var: "<<&var<<endl;
cout<<"Address of var: "<<p<<endl;
cout<<"Address of p: "<<&p<<endl;
cout<<"Value of var: "<<*p;
return 0;
}
Example 3: what is stdin in c
//stdin accesses the keyboard, it's a file pointer