#include <iostream>
#include <fstream>
using namespace std;
int main()
{
string mobile;
int N[10];
ofstream file;
file.open("my.txt");
cout<<"enter mobile ";
getline(cin, mobile);
file<<mobile<<endl;
cout<<"enter number ";
cin>>N[10];
file<<N;
file.close();
int a;
cin.ignore();
cout<<"press 1 to know details ";
cin>>a;
if(a==1)
{
ifstream file1;
file1.open("my.txt");
string str;
int num;
file1>>str;
file1>>num;
cout<<"company "<<str<<endl<<"number "<<num;
file1.close();
}
return 0;
}
string value is stored and read perfectly but the integer value entered is stored in the form of 0x61fdf0 and when it is supposed to again print, it always prints 0. I am trying to store a mobile number.
I am coding in code blocks.
Aucun commentaire:
Enregistrer un commentaire