Array vector has n elements, but lenght returns "n + 1" in C

1

Hello,

I have the following question: I have a vector and I'm sure it is passed to it only one element through the following loop:

char uid[1];
while(indice1 < indice2){
    printf("Valor de indice 1 %d, indice 2 %d\n", indice1, indice2);
    uid[indice0] = recvline[indice1];
    ++indice1; ++indice0;
}

By printing the index values they are respectively 11 and 12.

However, when I concatenate this string with another string through the strcat function or return its size using (int) strlen (uid), the size is 2.

I believe element '\ 0' should be suppressed in concatenation or element counting.

Any solution?

Thank you!

    
asked by anonymous 26.08.2017 / 13:47

0 answers