Hi i have a simple code which prints three characters of a charater array as shown below
void main()
{
char str[]={65,66,67};
printf("%.3s",str);
}
this gives the output ABC,but i was wondering since this is not a string means it is not null terminated then how can %s work on it and give the correct result?
Since you passed the length of the string, no 0 terminator is required by printf.