Thread: two things

  1. #1
    Registered User
    Join Date
    Nov 2003

    Question 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!

    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";

    for (i=1; i<=n; i=i+1)
    {cout<<"Enter Name\n";
    cin >>nme;
    cout<<"Enter Balance\n";
    cin >> balance;
    acct[i]=444+i ;
    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

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
     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.

    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Suggestions for things to study
    By Mastadex in forum Windows Programming
    Replies: 5
    Last Post: 08-18-2008, 09:23 AM
  2. Plants that eat things
    By StinkyRyan in forum A Brief History of
    Replies: 5
    Last Post: 07-05-2004, 03:41 PM
  3. How are things looking
    By cyberCLoWn in forum C++ Programming
    Replies: 8
    Last Post: 01-15-2004, 02:53 PM
  4. Selecting things on the canvas
    By Barjor in forum Windows Programming
    Replies: 0
    Last Post: 08-30-2001, 02:10 PM
  5. Help with these three things...
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 08-26-2001, 07:05 AM