Reading values into an array

This is a discussion on Reading values into an array within the C++ Programming forums, part of the General Programming Boards category; Hey guys I am getting an error that says: \main.cpp no match for 'operator>>' in 'std::cin >> *((+(((unsigned int)i) * ...

  1. #1
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,475

    Reading values into an array

    Hey guys

    I am getting an error that says:

    \main.cpp no match for 'operator>>' in 'std::cin >> *((+(((unsigned int)i) * 80u)) + brd)'
    All I am trying to do is read the elements into the 2d array. Is it saying I cannot
    use cin to do this?

    The below is the part of my proram which is the only part that has the error.
    I have marked the erorr line.

    Code:
    void move ( const int brd[][ 20 ] )
    {
       int i, j;
       int rowValue;
       int colValue;
    
       std::cout << "Enter number of rows to move: ";
       std::cin >> rowValue;
       std::cout << "Enter nmmber of columns to move: ";
       std::cin >> colValue;
    
       for ( i = 0; i < rowValue; i++ )
       {
          for ( j = 0; j < colValue; j++ )
             std::cout << "Enter value at position [ " << i << "][ " << j << "]: ";
             std::cin >> brd[ i ][ j ];  // ERROR IS HERE
       }
    }
    I'm just trying to be a better person - My Name Is Earl

  2. #2
    Registered User
    Join Date
    May 2006
    Posts
    903
    You need an opening bracket and an ending bracket for multi-line for loops.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,310
    I think the main problem is that you are trying to read into a const int. Try removing the const qualifier first, though I am not sure why the error message reads that way.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,793
    Code:
    void move ( const int brd[][ 20 ] )
    You're assigning values to an array that's declared const?
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  5. #5
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,475
    Thanks.

    The "const" was the reason. Technically I had made the array 'read only' hence the error. I anyone wants to know the IDE I use is WxDevC++ 6.10.2

    I could not work out the error, as the usually mean i have used >> and not <<
    I'm just trying to be a better person - My Name Is Earl

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 02-02-2009, 06:27 AM
  2. Reading a list of ints from file into an array
    By mesmer in forum C Programming
    Replies: 1
    Last Post: 11-10-2008, 05:45 AM
  3. copying values of an array to another array?!
    By webznz in forum C Programming
    Replies: 8
    Last Post: 10-24-2007, 10:59 AM
  4. question about multidimensional arrays
    By richdb in forum C Programming
    Replies: 22
    Last Post: 02-26-2006, 08:51 AM
  5. problem: reading user input into an array
    By alpha561 in forum C Programming
    Replies: 13
    Last Post: 05-24-2002, 07:23 PM

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