Thread: why does this function crash

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    43

    why does this function crash

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main ()
    {
        string dt[3];
        string stuff[3];
        stuff[1] = "Username: ";
        stuff[2] = "Password: ";
        stuff[3] = "Confirm Password: ";
                 
        for(int x = 0; x < 3; x++)
        {
        cout<<stuff[x]<<"\n";
        getline(cin, dt[x]);
        }
        
        cin.get();
    }
    nvm, array wasnt big enough
    Last edited by Mythic Fr0st; 01-17-2007 at 03:29 AM.

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    indexes of the array go from 0 to 2 not from 1 to 3
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 07:18 AM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM