Format string %n of printf function doesn't work

458 Views Asked by At
#include<stdio.h>

int main(){
    int a=100;
    printf("aaaaa%n",&a);
    printf("%d",a);
}

I used gcc to compile it ( :gcc a.c ) however, its output is as follows

aaaaa100

The value of a doesn't change by the printf's %n format string I suppose it should output as follows

aaaaa5

What is the reason of this unexpected difference? Thank you

0

There are 0 best solutions below