-
two things
I am taking a course called intro to prog concepts, psuedo-code, so my programming skills are currently limited. This may be a C question, but we use jgrasp in class and it is written in C++.
First, why doesn't this work? I want to load a customer, his account # and his balance. I have a book on C++ but cannot figure out how to load names into an array.
Second, I want to clear the screen at the end, how? I would appreciate any help!
[CODE]
#include<iostream.h>
#include<strstrea.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
void main()
{
char name[100],nme;
int acct[100],n, bal[100],key ,i, balance;
//Enter Customer Info
cout<<"How many customers will you be adding?\n";
cin>>n;
for (i=1; i<=n; i=i+1)
{cout<<"Enter Name\n";
cin >>nme;
cout<<"Enter Balance\n";
cin >> balance;
acct[i]=444+i ;
bal[i]=balance;
cout<<"Name :"<<name[i]<<", Balance :"<<bal[i]<<", Account Number :"<<acct[i]<<"\n";
}//end for
cout<<"Hit any key to clear screen";
cin>> key;
}//end info
:confused: :confused:
-
Code:
void main()
{
char name[100],nme;
1) 'main' always returns an int. Always.
2) 'name' is an array of 100 characters. That is, 100 single characters. This would be effective for holding one name, but not 100 names, unless each name was only 1 letter. Think of a 'char' as a single letter.
You likely want a 2 dimensional array. The first index is the name in the list, the second refers to the letter in the name.
Quzah.