Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 11-28-2006, 01:47 AM   #1 (permalink)
joelw
Code Monkey
 
Join Date: Sep 2006
Posts: 36
joelw is on a distinguished road
Help with storing data in structure

ok, i need help writing a program that stores data about a basketball player in a structue. I need to create a structure for players name, players number, and by points the player scored. I need to keep an array of 5 of these structures. Which each element is for a different player on a team. The program should ask the user to enter data for each player. It should then show a table of each players number, name, and points scored and finally it should calculate and display the total points earned by the team.

so far i have written this but some how i think im doing it wrong if anyone could help thanks in advance.

Code:
#include <iostream>
#include <iomanip>

using namespace std;

const int SIZE = 25;

struct Players
{
       char name[SIZE];        //Player's Name
       int playNum;            //Player's Number
       double Points;          //Point's Scored
};    

int main()
{
    const int NUM_PLAYERS = 5; //Number of Players
    Players players[NUM_PLAYERS];      //Array of sturctures
    int index;                 //Loop
    
    // Get Player data.
    cout << "Enter the players by ";
    cout << " players, numbers, and their scores.\n";
    for (index = 0; index < NUM_PLAYERS; index++)
    {
        cout << "Please enter players name: ";
        cin.ignore(); 
        cin.getline(players.name[SIZE];
joelw is offline   Reply With Quote
Old 11-28-2006, 06:05 AM   #2 (permalink)
toe_cutter
Code Monkey
 
Join Date: Aug 2002
Location: Boston, MA
Posts: 79
toe_cutter is on a distinguished road
Send a message via ICQ to toe_cutter Send a message via AIM to toe_cutter Send a message via Yahoo to toe_cutter
How do you think you are doing it wrong? I would recommend printing out the arrays after you fill them and see if your doing it right. Your example is also missing a couple of closing brackets, so I am not sure if there is more code or just those 2 brackets?

-tc
__________________
toe_cutter is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
question about what type of data to use DewKnight Everything SQL ( MySQL, MSSQL, DB2, Postgre, Oracle, etc...) 7 02-17-2006 11:59 AM
Reading chunks of data in a servlet??? j.gohel Java 2 09-10-2005 01:40 PM
confusion abt structure and class deepak_kr_mehta Standard C, C++ 1 05-14-2005 08:10 AM
? About data types... slashdot Standard C, C++ 2 04-15-2005 09:57 AM


All times are GMT -8. The time now is 11:28 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting