Adblock breaks this site

how would i..

Discussion in 'Programming General' started by SOFLYYO, Oct 14, 2012.

  1. SOFLYYO

    SOFLYYO Active Member
    Banned

    Joined:
    Nov 30, 2011
    Posts:
    154
    Referrals:
    0
    Sythe Gold:
    0
    how would i..

    go about getting user input and storing it into a char array?

    example:

    user enters in, "fdasfdsfsa fdsafsadf fdsafasfads" then "fdafsf fdsafasfasf fdasfasd"

    it prints out

    fdasfdsfsa fdsafsadf fdsafasfads

    fdafsf fdsafasfasf fdasfasd

    and it keeps looping while the user wants to do it? but at the same time storing the data in the array(s)
     
  2. Raid500

    Raid500 Forum Addict

    Joined:
    Feb 11, 2007
    Posts:
    592
    Referrals:
    1
    Sythe Gold:
    0
    how would i..

    I don't get what data you want to store in arrays? If it keeps looping that text then the array will just have a bunch of that text stored... Unless you want to store the number of loops which you can just do with an integer. Clarify your question.
     
  3. ladygaga

    ladygaga Member
    Banned

    Joined:
    Sep 14, 2012
    Posts:
    78
    Referrals:
    0
    Sythe Gold:
    0
    how would i..

    I would also like to know that , so please answer .
     
  4. Blupig

    Blupig BEEF TOILET
    $5 USD Donor

    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant
    how would i..

    You wouldn't use arrays if you want it to be indefinite, you'd use vectors. Here's the basic logic (forgive me this is totally freehand):

    Code:
    vector<string> blah;
    bool quit;
    string temp;
    int counter = 0;
    
    while (quit == false)
    {
    cin >> temp;
    if (temp == "quit") return 0;
    cout << temp << endl;
    vector[counter] = temp;
    temp = "";
    counter++;
    }
     
< Assistance | Advanced Applet Embedding in .NET >


 
 
Adblock breaks this site