Question:

I have a question in C programing

by  |  earlier

0 LIKES UnLike

Hi

I have a question in C programing.

Do you the meaning of s[N]= '\0' (we put null character in an array)?

Thanks

 Tags:

   Report

3 ANSWERS


  1. That is exactly what it means.

    You are setting the value of position N of array s to the null character.


  2. put a 0 into the N-th element of array s.

    i tried this:

    int s[3];

    s[2] = 10<<20;

    s[2] = '\0';

    and

    s[2] = 10;

    s[2] = '\0';

    in both cases the result is 0 (with gcc) so I deduce that '\0' (that should be a single char, 0 byte) is casted the right way to int, so the result is the right one (put a null byte at the nth position into the array)


  3. You're putting a null character at the Nth position of array s.  S is probably a string (array of characters) and the null character '\0' marks the end of the string.

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.