vendredi 28 août 2020

How does the following code works printf("%c")?

I wanted to know how the following program is working?

#include <stdio.h>
int main(void) {
    while(1){
        if(printf("%d",printf("%c")))
        break;
        else
        continue;
    }
    return 0;
}

I did not know how the part printf("%c") is working and therefore the whole program.I am aware of writing something like printf("%c", 'a'); like that but how is it working without providing the character to be printed? My question is what does the following program prints and how does it prints so?

I have tried to run the program, sometimes it prints nothing, but sometimes it is printing some random character followed by 1. I am not able to get how it is working, can someone please explain what is going behind the code and how it is printing that random characters, and why there is one at the end?

Here are some output I am getting

Output

Output

Aucun commentaire:

Enregistrer un commentaire