Unable to see how string is printed?

Unable to see how string is printed after the printf in the before line.

#include <iostream>
using namespace std;

int main() {
// your code goes here
char st[] = "CODING";
printf("While printing ");
printf(", the value returned by printf() is : %d", printf("%s", st)
return 0;
}

The output is:
While printing CODING, the value returned by printf() is : 6
Last edited on
You wrote this
1
2
3
printf("While printing ");
n =  printf("%s", st);
printf(", the value returned by printf() is : %d", n );


That is, you evaluated the result (and the side effect of seeing something) by calling printf("%s", st) before calling the final printf function to print the result.
Sorry, never saw such for long time. It is now visible that the contained printf () is printing earlier.
Topic archived. No new replies allowed.