printing 2d array with char

This is a discussion on printing 2d array with char within the C Programming forums, part of the General Programming Boards category; say if i have 2d char array like: hello world my name is david 2d array like this with 4 ...

  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
    32,822
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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, 02:01 AM
  2. newbie needs help with code
    By compudude86 in forum C Programming
    Replies: 6
    Last Post: 07-23-2006, 09:54 PM
  3. using selection sort with a 2D char array
    By kristentx in forum C++ Programming
    Replies: 12
    Last Post: 04-08-2006, 08:45 AM
  4. code condensing
    By bcianfrocca in forum C++ Programming
    Replies: 4
    Last Post: 09-07-2005, 10:22 AM
  5. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 12:58 PM

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