1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Any one can help with c++ array?

Discussion in 'Software Development' started by bubblepantz, Sep 28, 2008.

Thread Status:
Not open for further replies.
  1. bubblepantz

    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");
                                                                                       
         
         }
                                                    
    
     
  2. mt2002

    mt2002

    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;
    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.
     
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 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/754028

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice