Why is snprintf giving different value in second case. Is it because any integer limit. Can you please explain how snprintf works and why the reason for that negative value
#include <stdio.h> #include <string.h> main() { char buff[256]; snprintf(buff,256,"%s %d"," value",1879056981); printf("%s",buff); } output: value 1879056981
#include <stdio.h> #include <string.h> main() { char buff[256]; snprintf(buff,256,"%s %d"," value",2415927893); printf("%s",buff); } output: value -1879039403
%luinstead. Because, it's for 64bit int!