Thread: printing 2d array with char

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    3

    printing 2d array with char

    say if i have 2d char array like:

    hello
    world
    my name is
    david

    2d array like this with 4 lines and max 128 chars in a line
    char array[4][128]
    how do i print them like above?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Code:
    for ( i = 0 ; i < 4 ; i++ ) printf ( "%s\n", array[i] );
    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.

  3. #3
    Registered User
    Join Date
    Sep 2005
    Posts
    3
    thanks!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. newbie needs help with code
    By compudude86 in forum C Programming
    Replies: 6
    Last Post: 07-23-2006, 08:54 PM
  3. using selection sort with a 2D char array
    By kristentx in forum C++ Programming
    Replies: 12
    Last Post: 04-08-2006, 07:45 AM
  4. code condensing
    By bcianfrocca in forum C++ Programming
    Replies: 4
    Last Post: 09-07-2005, 09:22 AM
  5. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM