samedi 2 juin 2018

Why this wrong syntax of printf is not producing error in c?

I have used this syntax for printing some variable n. I know that the syntax is wrong but was not able to understand what is happening behind the scenes. It is not even creating an error. Inside the main method:

int fac,p=1,n,i;
printf("Enter the value of n \n");
scanf("%d",&n);
printf("The factorial is \n %d"+n);

I have used +nin last line and that is not the right syntax. Output is:

factorial is
1

can someone help me to figure out what is happening behind the scenes. How is compiler understanding that +n in print function.

Aucun commentaire:

Enregistrer un commentaire