3
#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

GoodDeeds
  • 7,956
  • 5
  • 34
  • 61
peng xu
  • 385
  • 1
  • 3
  • 6

0 Answers0