i have declared an array a[20]

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Aniruddha Gohad

    i have declared an array a[20]

    a[20] and have scanned a name.
    what will happen if all 20 memory allocations
    arent used. i want to print the name in reverse.
    will blank spaces be printed before the name??
  • JavierL
    New Member
    • Apr 2010
    • 17

    #2
    It will print gargbage if you havent initialized it, you can also put some character that you want in the non used chars and with an if print everything skipping those chars.

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      I assume that you mean that your 20-element array contains a null-terminated string whose length is less than or equal to 19. To print this string backwards you need to find the character preceding the terminating null and then print each character from there back to the beginning of the array.

      Comment

      Working...