Thread: Simple question about arrays

  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    5

    Simple question about arrays

    See, I've got a 2 dimensional array, let's call it "myarray" for simplicity.
    myarray is 8 on 8 (myarray[8][8]).

    Now assuming I want to put an 8 bit word in myarray[0][0-7].
    Is there any way I can put it whole? Like " myarray[0]=10100110; " ?
    That doesn't compile, but that's just an example.
    I'd think there'd be a way to put it together, and not one by one, but I can't seem to find it.
    Do I really to change each "tile" on its own?

    Thanks, tima.

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,794
    Code:
    int myarray[8][8]={{1,0,1,0,0,1,1,0}};
    all members left not initialized during declaration will be initialized to 0 (if at least one member of the array was initialized explicitely.
    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

  3. #3
    Registered User
    Join Date
    May 2007
    Posts
    5
    Quote Originally Posted by vart View Post
    Code:
    int myarray[8][8]={{1,0,1,0,0,1,1,0}};
    all members left not initialized during declaration will be initialized to 0 (if at least one member of the array was initialized explicitely.
    I don't want to set it during declaration, because the array changes according to what I type.
    I want to do it in the middle of the code.

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,794
    Quote Originally Posted by tima View Post
    I don't want to set it during declaration, because the array changes according to what I type.
    I want to do it in the middle of the code.
    Then you need to write a loop
    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. Replies: 2
    Last Post: 01-30-2009, 05:58 AM
  2. Simple question about the C programming tutorial #1
    By elsheepo in forum C Programming
    Replies: 13
    Last Post: 01-19-2009, 08:59 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Question on Arrays
    By shin in forum C Programming
    Replies: 10
    Last Post: 06-06-2004, 01:11 PM
  5. simple input and string manipulation question
    By Stig in forum C Programming
    Replies: 1
    Last Post: 12-15-2001, 01:33 PM