+ 6
switch case
why in this switch case the program executes the third case ??! cause we have 3 characters (h i -)?? switch (printf("hi-")) { case 1: printf ("a"); break; case 2: printf ("b"); break; case 3: printf ("c"); break; default: printf ("default"); } //result hi-c
1 ответ
+ 2
Yes, that seems to be true:
https://code.sololearn.com/cO73iv1EZ16s/?ref=app
That might be because the printf is a function which actually writes text to a file, which will be used by command prompt to display data on the screen.
In Python you can write data to a file using write method and the written amount of characters will be returned as an integer.
Because printf also actually writes data to a file it could also return the amount of written characters.