two things

This is a discussion on two things within the C++ Programming forums, part of the General Programming Boards category; I am taking a course called intro to prog concepts, psuedo-code, so my programming skills are currently limited. This may ...

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    4

    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!



    [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

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    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.
    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 Cprogramming.com
    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, 01: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21