#include<iostream>
#include<fstream>
#include<string>
using namespace std;
struct phonenode{
char surname[15];
char initals[4];
phonenode *next;
};
phonenode *start_ptr = NULL;
phonenode *crrnt_ptr;
void read_txt(){
ifstream ifs("test.txt");
char surn[15];
char inital[4];
phonenode *temp1, *temp2;
temp1 = new phonenode;
if (ifs.fail()){
cout << "ERROR" << endl;
}
while(ifs.good()){
ifs>>surn>>inital;
if(ifs.fail()){
break;
}
surn >> temp1->surname;
inital >> temp1->initals;
if (start_ptr == NULL){
start_ptr = temp1;
crrnt_ptr = start_ptr;
}
else{
temp2 = start_ptr;
while (temp2->next != NULL){
temp2 = temp2->next;
}
temp2->next = temp1;
}
}
ifs.close();
}
void main(){
read_txt();
system("PAUSE");
}
above code is mine.. and I'm new to C++.
in "test.txt"
abcd H.J.
efc K.W.
I want to read text and want to put in linked list; however, I got some errors
error C2296: '>>' : illegal, left operand has type 'char [15]'
error C2297: '>>' : illegal, right operand has type 'char [15]'
error C2296: '>>' : illegal, left operand has type 'char [4]'
error C2297: '>>' : illegal, right operand has type 'char [4]'
sorry for noob question but... how can I fix these problem?