K
karthikbalaguru
Hi,
In the below code, i get a strange output.
int main(void)
{
int a=2;
printf( "ABC %d Ok\n", a );
printf( "ABC %d Ok\n", &a );
printf( "ABC %n Ok\n", &a );
printf( "a = %d\n", a );
return 0;
}
I get the below output -
ABC 2 Ok
ABC 2162224 Ok
ABC
Before exeuction of the final printf, it showed
a warning. Then, it printed only ABC.
I did not get that 'Ok'. Why ?
Further it also did not print 'a = 3' ?
I am eager to know the logic behind %n ?
Does it count and store the characters until it
faces a space or % ?
Thx in advans,
Karthik Balaguru
In the below code, i get a strange output.
int main(void)
{
int a=2;
printf( "ABC %d Ok\n", a );
printf( "ABC %d Ok\n", &a );
printf( "ABC %n Ok\n", &a );
printf( "a = %d\n", a );
return 0;
}
I get the below output -
ABC 2 Ok
ABC 2162224 Ok
ABC
Before exeuction of the final printf, it showed
a warning. Then, it printed only ABC.
I did not get that 'Ok'. Why ?
Further it also did not print 'a = 3' ?
I am eager to know the logic behind %n ?
Does it count and store the characters until it
faces a space or % ?
Thx in advans,
Karthik Balaguru