Hi im creating a linked list with these data types
int account_number
char firstName[10]
char lastName[10]
float total_Balance

would anyone give a simple instruction to input/output these. i have tried everything but still doesnt work so far i have done this.

using namespace std;
struct account_query
int account_number;
char firstName[10];
char lastName[10];
float total_Balance;
struct link
account_query data;
link * next;

class Records
link * first;
Records( )
{ first = NULL; }
void write_rec( );

  void Records::write_rec()
          link *newlink;
          newlink=new link;
          cout<<"please enter account_number";
 cin>>newlink->link->data->account_query->account_number; //problem
          cout<<"please enter firstName";
 cin>>newlink->firstName;                                //problem
          cout<<"please enter lastName";
 cin>>newlink->lastName;                                //problem
          cout<<"please enter total_Balance";
  cin>>newlink->total_Balance;                          //problem
          newlink->next = first;
          first = newlink;

void main()
Records s;


Edited 3 Years Ago by pritaeas: Moved to C++

line 13 should be cin>>newlink->link->data->account_number; Compare that with the other errors you posted and you will see what's wrong with them.

Edited 3 Years Ago by Ancient Dragon


you created an object from link that named newlink.you dont use of struct type "link" in statements.the case of account_query is similar too.
instead you should use of objects name's.
link ---> newlink
account_query ---> data

This article has been dead for over six months. Start a new discussion instead.