Thread: Arrays

  1. #1
    Banned
    Join Date
    Apr 2015
    Posts
    596

    Arrays

    Hi, I'm wondering if there's a specific symbol in C programming thats simplifying the final of the array, like we have in strings "\0" which tells we arrived to the final of the string!...is there something like that?


    thanks and sorry if the question is so trivial!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    For arrays of all other types, you need to define your own sentinel value, or just keep a count of the number of valid elements in the array.
    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 MartinR's Avatar
    Join Date
    Dec 2013
    Posts
    200
    well there is no "string" data type in C, you can create something like string using array of chars or array of pointers to char. As as far as I know only array of pointers to char has '\0' appended at the end of the array. On the other hand when I compile C99 code all arrays end with NULL but it's not guaranteed by the standard so you shouldn't use it - in general it may be NULL but most probably will be some garbage there.

  4. #4
    Banned
    Join Date
    Apr 2015
    Posts
    596
    Quote Originally Posted by MartinR View Post
    well there is no "string" data type in C, you can create something like string using array of chars or array of pointers to char. As as far as I know only array of pointers to char has '\0' appended at the end of the array. On the other hand when I compile C99 code all arrays end with NULL but it's not guaranteed by the standard so you shouldn't use it - in general it may be NULL but most probably will be some garbage there.


    Alright got you.


    And for not opening a new thread...can you please tell me if I can change a value of a unary array with a matrix's value such as : (4,5) ?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Passing arrays and string arrays to functions
    By codeer in forum C Programming
    Replies: 2
    Last Post: 03-25-2015, 10:07 AM
  2. Replies: 3
    Last Post: 07-01-2014, 07:48 AM
  3. Replies: 9
    Last Post: 07-11-2013, 10:57 PM
  4. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  5. Replies: 2
    Last Post: 02-23-2004, 06:34 AM