#include <iostream>
#include<fstream>
using namespace std;
int main()
{
int a;
cout<<"enter key ";
cin>>a;
if(a==1)
{
string info[0][1];
cout<<"enter your name ";
getline(cin, info[0][0]);
cout<<"enter father's ";
getline(cin, info[0][1]);
ofstream file("info.txt");
for(int i=0;i<=1;i++)
{
file<<info[0][i]<<" ";
}
file.close();
}
int b;
cout<<"enter b ";
cin>>b;
if(b==2)
{
char info[0][1];
ifstream file("info.txt");
for(int j=0;j<=1;j++)
{
file>>info[0][j];
}
cout<<endl;
for(int i=0;i<=4;i++)
{
cout<<info[0][i]<<" ";
}
}
return 0;
}
I want to store user and his father's name (other info as well which is not mentioned in code) in the form of 2d array, and ofstream that array and later ifstream the same.
in the code:
After taking input a=1, it displays "enter your name", to which it is not taking any input i.e nothing gets typed in the output window from keyboard. (no compiler error) Please help!!
I am coding in code blocks.