29th Jun 2020, 4:41 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
12 Respuestas
+ 8
Samanvitha P R yeah am getting same output
29th Jun 2020, 5:08 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 8
Martin Taylor thanks for explanation i understood very well
29th Jun 2020, 5:43 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 7
Samanvitha P R but why its printing @
29th Jun 2020, 5:00 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 6
Samanvitha P R sorry i understood because size was less so its printing garbage now i increased the length then its printing properly but why %s not printing two times
29th Jun 2020, 5:14 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 6
Dennis yes i understood but wht %s not printed two times
29th Jun 2020, 5:15 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 6
Dennis ohh i understood thanks
29th Jun 2020, 5:16 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
Because the first parameter of printf is a format specifier which replaces the formats "%s" in this case with the 2nd and so on parameters. ( even if you don't provide one, so be careful there ) The 2nd parameter and so on don't have this behaviour.
29th Jun 2020, 5:15 PM
Dennis
Dennis - avatar
+ 1
Your character array is not big enough to include the null character so anything can happen when it tries to print it.
29th Jun 2020, 5:12 PM
Dennis
Dennis - avatar
0
Martin Taylor your explanation is very clear man . Thank you.
24th Sep 2020, 7:50 AM
Pon Balaji
Pon Balaji - avatar