ca anyone help me... i am having a problem of my c++ code.. im still a begineer in c++ and i want to creat a program that searches and input an ID number and reading the whole line..this is my sample txtfile
Record2.txt
101,Kirviepalencia,500.00
102,ALmond Olilang,700.00
103,Krishna Laguardia,200.00
104,Carl Kabalyero.300.00
Output:
Enter ID: 101
101,Kirviepalencia,500.00
Enter ID: 104
104,Carl Kabalyero.300.00
i included my program here.. hope anyone can help me here..thanks in advance..
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char *argv[])
{
ifstream kirviealmond ("Record2.txt");
if(!kirviealmond) {
cout << "Cannot open input file.\n";
return 0;
}
char str[255];
char ble[255];
while(kirviealmond) {
cout<<"enter id number:";
cin>>str,ble;
kirviealmond.getline(str, 255),(ble,255); // delim defaults to '\n'
if(kirviealmond) cout << str<<ble<< endl;
}
//else if
kirviealmond.close();
return 0;
}