Thread: i don't succeed into making an array of 20 lines and 20 columns filled with zeros

  1. #16
    Registered User
    Join Date
    Feb 2013
    Posts
    54
    i've already done that ( learn on tutorials, before asking you questions, and open a good C++ book), but despite that, for now i don't succeed into doing what i want to do, but i'll keep doing my best and i'll quickly stop to ask you such basic questions.

    Now i've completed what you sent me, but i get plenty of error stray '...' in program
    Here is my code :
    Code:
    #include <iostream>      
    #include <iomanip>        
    #include <cstdlib>        
    
    
    using namespace std;
    
    
    void initArray(int largeArray[20][20])
    {
        for (int x = 0; x < 20; x++)
        {
            for (int y = 0; y < 20; y++)
            {
                largeArray[x][y] = 0;
            }
        }
    }
    
    
    
    
    void printOutArray(int largeArray[20][20])
    {
      int x;
     int  y;
     for (int x = 0; x < 20; x++){
                                                for ( y = 0 ; y<20; y++ ){
                                                cout<< largeArray [x] [y]<<'\t' ;
                                                        }
          cout << endl ;
        }
    
    
    }
    
    
    int main()
    {
        int largeArray[20][20];
        initArray(largeArray);
        printOutArray(largeArray);
        system("PAUSE");
    }

  2. #17
    Registered User
    Join Date
    Feb 2013
    Posts
    54
    What's wrong in this code please? Why do i have so many error stray '...' in program?

  3. #18
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    That should be fine (it works here).

    The only thing I saw was this.
    Code:
    $ g++ -Wall -Wextra foo.cpp
    foo.cpp: In function ‘void printOutArray(int (*)[20])’:
    foo.cpp:25:7: warning: unused variable ‘x’ [-Wunused-variable]
    > Now i've completed what you sent me, but i get plenty of error stray '...' in program
    You typically get that when you just copy/paste code direct from the internet. Especially code which has been "pretty-printed" into HTML with dumb things like ' ' replaced with "smart quotes".
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #19
    Registered User
    Join Date
    Feb 2013
    Posts
    54
    Ok now it works : all my "error stray '...' in program" went away when i typed in again in another project the same code exactly ( except for int x and int y in voidprintOutArray that i deleted, and i added the "int" before y that was missing in the loop for in this function). Thank you all !!
    Thank you Salem !!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking to see if an array is filled
    By ljgerr93 in forum C Programming
    Replies: 5
    Last Post: 10-17-2011, 12:48 PM
  2. making rows in terms of columns?
    By x2x3i5x in forum C Programming
    Replies: 2
    Last Post: 11-30-2009, 11:53 PM
  3. File handling with Array filled with a class
    By MarlonDean in forum C++ Programming
    Replies: 18
    Last Post: 06-27-2008, 10:53 AM
  4. Replies: 3
    Last Post: 11-16-2007, 03:10 PM
  5. Filled array
    By GaPe in forum C Programming
    Replies: 2
    Last Post: 12-11-2001, 05:36 AM