Any one can help with c++ array?

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

bubblepantz

Thread Starter
Joined
Mar 21, 2008
Messages
56
Im very new to C++ and im using the program as sort of a comprhension check on what i know so far. im stuck bc of an array. i want to change the value of an int to an array value based on a selection. such as:
entry.orville based on user input changes to entry.orville[0][0]; something along those lines. Any help is sooo much apprciated.:D

Code:
#include <iostream>	

using namespace std;

struct database { 
           int orville;
           int tiffany;
           int robin;
           int dawn;
           int dad;
           int mom;
           int choices;
           int arraychoices;
           
           };
		
int main()
{
    system("TITLE Orville .1");
    database entrys;
    entrys.orville;
    entrys.tiffany;
    entrys.robin;
    entrys.dawn;
    entrys.dad;
    entrys.mom;
    entrys.choices;
    entrys.arraychoices;
    
        
    cout<< "Welcome to the box." << endl;
    cout<< "In this im displaying my knowledge of what ive learned about in C++ this far" << endl;
    cout<< "Please select a choice to continue:" << endl;
    cout<< "1. Orville 2. Tiffany 3. Robin 4. Dawn 5. Dad 6. Mom" << endl;
    cin>> entrys.choices;
    cout<< "Next we will want to put these values into an array(grid)" << endl;
    cout<< "Select where you would like Orville to go," << endl;
    cout<< "Remember, this is a 6x6 grid" << endl;
    cout<< "1.1x1 square 2.2x2 square 3.3x3 square" << endl;
    cin >> entrys.arraychoices;
    int simplearray[7][7];
    
    
    
switch (entrys.arraychoices) 
{
       case '1':
            cout << "Orville has been placed in the 1x1 sqaure" <<  << endl;
            break;
            case '2':
                 cout << "Orville has been placed in 2x2 on the grid" <<  << endl;
                 break;
                 case '3':
                      cout << "Orville has been placed in 3x3" <<  << endl;
                      break;
                      default:
                              cout << "!! Warning: Please select a proper action !!" << endl;
                              break;
                              }
                              
                      
                
    
    
    

switch (entrys.choices) 
{
 
           case 1:
               cout << "Orville, the Lil Brother" << endl;
               break;
           case 2:
               cout << "Tiffany, the Lil Sister" << endl;
               break;
           case 3:
               cout << "Robin, The Big Sister" << endl;
               break;
           case 4:
               cout << "Dawn, The Medium Sister" << endl;
               break;
           case 5:
               cout << "Big Pappa" << endl;
               break;
           case 6:
               cout << "The *****" << endl;
               break;
               default:
               cout << "!! Warning: Please select a proper action!!" << endl;
               break;
                                                                                   
}
     system("pause");
                                                                                   
     
     }
 
Joined
Sep 14, 2005
Messages
919
None of these lines are needed and can be (and recommended) to be removed. Smart compilers will remove them anyways for you as they do nothing:

Code:
entrys.orville;
entrys.tiffany;
entrys.robin;
entrys.dawn;
entrys.dad;
entrys.mom;
entrys.choices;
entrys.arraychoices;
entry.orville based on user input changes to entry.orville[0][0]; something along those lines.
You cannot change an int into an array (Not directly, anyways.) If you know the size of the array, make orville an array in your structure and just set the corresponding index to the value that you want.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top