i am using ubuntu and g++ compier
while making a program of data file handling .
the program is error free
in this i ve created a text file and asked the user to input name and roll no. but when i input the just the first name the program is running fine .. but when i input the full name aong with a space , the first input goes in correct but junk values get stored in the rest . please help so that i can input the full name along with the spaces and the loop runs fine .
the code is
#include<iostream>
#include<fstream>
#include<cstdlib>
using namespace std;
int main()
{ fstream f1;
f1.open("stud.txt",ios::in);
int rno[5];
char name[5][100];
int i;
for(i=0;i<5;i++)
{ cout<<"\n enter the roll number ";
cin>>rno[i];
cout<<"\n enter the name ";
cin >>name[i];
f1<<rno[i];
f1<<name[i];
}
f1.close();
f1.open("stud.txt",ios::out);
for(i=0;i<5;i++)
{ cout<<"\n the roll number and name is";
f1>>rno[i];
f1>>name[i];
cout<<" roll no "<<rno[i]<<" name is "<<name[i]<<"\n";
}
}
Hey Guys according to that topic i think that If you are a developer you need C and C++ Compiler for your growth perform.In ubuntu you can set up the build-essential for C and C++ compilers.For gaining complete detail about that must visit that url: