programming question

Discussion in 'OT Technology' started by CaracicatriZ, Oct 11, 2007.

  1. CaracicatriZ

    CaracicatriZ this fucking guy OT Supporter

    Joined:
    Sep 25, 2005
    Messages:
    1,366
    Likes Received:
    0
    Location:
    Houston - Texas
    ok so i need to put UP TO 20 strings into an array and then display them in reverse order, so far ive gotten:
    #include "stdafx.h"
    #include <string>
    #include <iostream>
    using namespace std;


    int main()
    {

    string stuff[20];
    int numb;

    cout<<"How many things would you like to enter?"<<endl;
    cin>>numb;

    if(numb<=20&&numb>1)
    {cout<<"Enter anything."<<endl;
    cin>>stuff[20];
    cout<<endl;
    }
    else
    {cout<<"You entered a number over 20 or a number under 0."<<endl;
    cout<<endl;}

    return 0;
    }


    but it only lets me input one thing, havent even attempted an output or reverse order since i cant even get it to enter up to x amount of things. Any help would be appreciated.
     
  2. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    hint: loop
     
  3. Corp

    Corp OT Supporter

    Joined:
    Sep 11, 2003
    Messages:
    28,201
    Likes Received:
    0
    Location:
    Providence, RI
    inside the if statement add a while loop that loops while a counter variable(usually called i) is less than numb
     

Share This Page