Thread: Initialzing a 2D character array

  1. #1
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218

    Initialzing a 2D character array

    I'm writing a function that draws fonts from a binary mask. I havent got very far as I can't remember how to initialize a 2d character array.

    heres what i got:
    Code:
    char mini_text[10][7]="]fjjjr]", "0", "0", "0", "0", "0", "0", "0", "0";
    Theres basically 10 array elements for characters 0 to 9, and each characters consists of 7 other characters each representing a scanline. How can I initialize this?

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    hint: { and }

    eg,
    Code:
    char mini_text[10][7] = {"]fjjjr]", "0", "0", "0", "0", "0", "0", "0", "0"};
    But perhaps a bitset is better? Eg an array of bitted chars (you have only 7 characters, which would fit into a int8 (char)...).

  3. #3
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    Cheers. That was a bit of a dumb mistake.

    But perhaps a bitset is better? Eg an array of bitted chars (you have only 7 characters, which would fit into a int8 (char)...).
    I dont quite get what you mean here. I guess I could code it using 5 characters instead of 7 reading the binary patterns vertically instead, but that seems like more hassle than its worth for just shaving a couple of characters off.

  4. #4
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Never mind, it wasn't really efficient after all or even relevant, my bad

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 2D array of threads?
    By shorinhio in forum C Programming
    Replies: 2
    Last Post: 01-04-2007, 04:02 PM
  2. Dictionary into a 2d Char Array... Problems.
    By Muzzaro in forum C Programming
    Replies: 10
    Last Post: 12-02-2006, 12:34 PM
  3. passing/pointing to a 2d array
    By jamie85 in forum C Programming
    Replies: 7
    Last Post: 10-28-2005, 10:16 PM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  5. Help with 2-D character array
    By choykawairicky in forum C++ Programming
    Replies: 2
    Last Post: 05-15-2004, 12:12 AM