can't get an array to show.

This is a discussion on can't get an array to show. within the C++ Programming forums, part of the General Programming Boards category; how would i get it to repeat the array that the user puts in ? my current output i get: ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    13

    can't get an array to show.

    how would i get it to repeat the array that the user puts in ?

    my current output i get:

    "Please enter the size that you would like of an array from 0-100 :
    3
    Now enter 3 characters :
    1
    2
    3
    The numbers you entered are: -858993460Press any key to continue"


    Code:
    #include<iostream>
    
    using namespace std;
    void deleterepeats(char a[], int& arraysize);
    
    int main ()
        {
         int index_used = 0;
            int arraysize, a[100];
          
     
            cout<<"Please enter the size that you would like of an array from 0-100 : \n";
            cin >>arraysize;
    
            cout<<"Now enter "<< arraysize<<" characters :\n";
        
    
            int k= 0;
            
            while (k<arraysize)
            
                {
                cin>> a[k];
                k++;
                }
    
           cout <<"The numbers you entered are: ";
            
          
    	   for (int index = 0; index < arraysize; index++);
    	   {
    			
    		   index++;
    
    		   cout << a[index];
    	   }
    	   
    	   
        
      
        
        return 0;
    
        }
    Last edited by IXxAlnxXI; 10-31-2006 at 03:18 AM.

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Code:
    for (int index = 0; index < arraysize; index++) //remove it ;
    	   {
    			
    		   // remove it index++;
    
    		   cout << a[index];
    	   }
    see comments
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    Code:
    cout<<"Now enter "<< arraysize<<" characters :\n";
    Perhaps you should prompt for numbers, not characters . . .

    Code:
    cout << a[index];
    You might want to print some whitespace after this, such as a newline or a space, because otherwise the numbers in your output will run together; that is, if a[] contains (1, 2, 3, 55, 99), your program would print "1235599".
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  2. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 10:33 AM
  3. Array of Pointers to Arrays
    By Biozero in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 02:31 PM
  4. Replies: 6
    Last Post: 11-09-2006, 02:28 AM
  5. Type and nontype parameters w/overloading
    By Mr_LJ in forum C++ Programming
    Replies: 3
    Last Post: 01-02-2004, 12:01 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21