Input file line help

there is a file called "customer.dat"

the contents of the file are as follows

230#Louis Christakes#1000#500
312#Hasnain Attarwala#0#6959
999#Gojodhar Bhaiya#0#0
007#James Bond#100#0

(could be more or less, but in that format)
the first three numbers(or letters) are the account number
after the # sign its the first name
after a space its the last name
after the # sign its the checking balance
and last is the savings balance

i need to input this data into something so i can work from, in my program,
example, my program would just ask for the account number, and tell you the name of the person (full name), and his checkings and savings balance, so i was thinking of a parallel array.

but i am having a hard time that how would i get an input which seprates words using a # symbol and names using a space,

i was thinking i could do something like this, please help

int load customers ()
char firstName[20];
char lastName[20];
char fullName[40];
char line;
int accNumber;
int chkBalance, svgBalance;

if stream inputFile;

int count = 0; // to keep a total of how many lines (customers we loaded)"customer.dat");
while (!input.eof())
input.getline(input, line);
for (int i =0; i<= count; i++)


//strcpy (name[count], firstName);
//strcat (name[count], " ");
//strcat (name[count], lastName);


this is how much i have so far, i know its not much, but i am really confused of how would i input a line, count number of lines.
seprate the variables such as acctNumber, Name, chkBalance, svgBalance
by # sign

and save the whole name in the variable name, instead of using firstName and Lastname,

also every line has to be in a type of a parallel array so that i wont change the checking balance of some other guy... Please help, i am really confused

These are the instructions for the entire program, if i can get how to do the input properly, with respect to this, i think i would be able to write the whole project.

Structure Needed (account)
 Char acctNum[4]
 Char name[30]
 Float cBal
 Float sBal
Functions Needed
 Int Menu() – Display main menu and get choice. Validate to make sure
you get a valid choice.
 Char submenu() – Display the choice for checking or savings account
and return a valid choice.
 Int loadCustomers(account []) – Open the customer.dat file and read in
all of the current accounts. The fields are separated with a ‘#’ pound sign.
Return the number of customers loaded.
 Void saveCustomers(account [], int) – Write all of our customers out to
the original customer.dat. You have to put in the ‘#’ pound sign yourself.
Make sure not to put an extra line break on the last customer.
 Int newCustomer(account [], int) – Add a new customer to the end of
the array. Initialize their two accounts to 0.00. Returns the new number of
 Int deleteCustomer(account [], int) – Ask for the acctNum and find the
customer and delete. If the acctNum is not valid, do nothing. Return the
new number of customers.
 Int findCustomer(account [], int) – Ask for the acctNum and return an
index to the customer. If not found return -1.
 Void deposit(account [], int) – find the customer and then depending
upon savings or checking add the amount.
 Void withdrawal(account [], int) – find the customer and then depending
upon savings or checking decrement the amount. If the withdrawal is
more than in the account, print a message and then do nothing.
 Void balance(account [], int) – find the customer and display their
 Void bankBalance(account [], int) – total up the amounts in all of our
accounts by checking and savings.
Main function
 Create an array of 20 accounts
 Keep a variable to keep track of how many accounts we currently have
 Load customers
 Loop and do work based on user input
 When user exits save your array back to the original file
Topic archived. No new replies allowed.