1
Hello, could someone please explain to me what is happening in this tie stop condition for?
#include <stdio.h>
int main(void) {
char frase[] = "Linguagem C";
for(int i = 0; frase[i]; i++) { //frase[i]?
printf("%c", frase[i]);
}
return 0;
}
The output is: C language
I’ve used the for several other times, but I’ve never seen a condition like this.
In the example below, it is displayed in addition to the int vector content:
#include <stdio.h>
int main(void) {
int vetor[] = {34, 42, -12, 984, 86, 14};
for(int i = 0; vetor[i]; i++) { //A condição de parada é vetor[i]
printf("%d\t", vetor[i]);
}
return 0;
}
The output is: 34 42 -12 984 86 14 1 7 136112
I believe the values from 14 are probably "junk in memory".
But why does it happen?
wants to know why the memory junk?
– Ricardo Pontual
Yes; I think they are values stored in RAM because of other applications, but I would like to read your explanation please.
– Dead