array confusion (int vs char)

This is a discussion on array confusion (int vs char) within the C Programming forums, part of the General Programming Boards category; i was reading a text which stated an integer array for e.g Code: int array[5]; can store 5 elements where ...

  1. #1
    Registered User
    Join Date
    Feb 2012
    Location
    Trinidad & Tobago
    Posts
    43

    array confusion (int vs char)

    i was reading a text which stated an integer array for e.g
    Code:
    int array[5];
    can store 5 elements where ,as character array
    Code:
    char array[5]={"abcd"}
    can store 4 elements

    is this true ?
    can someone please clarify this for me
    thank u.

  2. #2
    Registered User camel-man's Avatar
    Join Date
    Jan 2011
    Location
    Under the moon
    Posts
    643
    It actually stores 5 characters, one being the null terminating character '\0'

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Confusion with fread from .txt array in C
    By dm14v07 in forum C Programming
    Replies: 2
    Last Post: 05-02-2011, 08:32 PM
  2. Replies: 3
    Last Post: 11-17-2008, 12:36 PM
  3. char variable[#] - confusion
    By Chris2222 in forum C Programming
    Replies: 8
    Last Post: 09-28-2007, 12:53 AM
  4. char confusion
    By noodles in forum C Programming
    Replies: 6
    Last Post: 06-24-2006, 12:32 PM
  5. array and char confusion
    By hanhao in forum C++ Programming
    Replies: 1
    Last Post: 03-13-2004, 05:59 AM

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