+ 11
cout << printf; // output: 1
Why do I get a 1 as output if I cout a function name?
13 Respuestas
+ 11
~ swim ~ If printf returns the no of chars then can we write like this
int charsCount = printf("Hello");
OR
char arr[] = "Hello";
int charsCount = printf("%s", arr);
Which piece of code is valid or invalid?
+ 10
Alright, thank you for answering :)
+ 7
How about:
int arr[printf("Weird sizing")];
That gonna work? 😁
So basically if I cout a function name I get the answer: "Yep, this function does exist."
Thanks, ~ swim ~!
+ 6
~ swim ~ i thought the return value of printf function is 1
+ 6
Yeah, Jay, that's the usual return value.
I knew about that before; I didn't know you can bool a function though.
+ 5
~ swim ~ I think you meant nAutAxH AhmAd and not *AsterisK* in one of your comments above. They both have darkish avatars and nearly fooled me too.
0
When you write any function name without the parentheses it gives you the address of that function, since printf exists the adress is more than 0 which returns true.