Thread: printing arrays with concatenation

  1. #1
    Registered User
    Join Date
    Jul 2005

    printing arrays with concatenation

    for example i want to use 25 arrays with 6 elements each:
    cell2[]={7,8,9,10,11}.... until cell25[]
    i want to print the content of a cell depending on its number:
    for example, i typed 1, then it will print the elements inside cell1.
    i don't want to use the if statement coz the code will be very long, i guess. Instead i would like to use concatenation
    is it possible for given a variable for the input as n, can i do this
    in this manner i dont have to write many if statements
    i know there is an error... that's why i need your help...i hope i
    have described my question clearly... thanks..

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Instead of
    Why not
    cells[2][6 ]= {
    Then nested for loops work just like you want them to.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Printing String Arrays
    By kwikness in forum C Programming
    Replies: 6
    Last Post: 10-08-2007, 01:44 AM
  2. Printing arrays to curses screen
    By trev456 in forum C++ Programming
    Replies: 4
    Last Post: 05-07-2007, 12:46 AM
  3. Loop printing arrays
    By CHurst in forum C Programming
    Replies: 2
    Last Post: 12-14-2005, 08:13 PM
  4. New to C, printing arrays
    By kidglove14 in forum C Programming
    Replies: 1
    Last Post: 02-26-2002, 03:32 PM
  5. Printing back arrays
    By Intimd8r in forum C Programming
    Replies: 3
    Last Post: 10-01-2001, 12:50 PM