How to input/output & compare "long long" variables in C?
I wrote a program in C. My purpose is testing how "long long" variables work. But the resule comfuse me.
My OS : WinXP My compiler: TCC (Tiny C Compiler) http://bellard.org/tcc/ version 0.9.25 ======== My Source code ========# include "stdio.h"
# include "math.h"
void main() {
long long n,i;
scanf("%lld",&n);
i=42;
printf("\nn=%lld",n);
printf("\ni=%lld",i);
printf("\ni<=n --> %d",i<=n);
return;
}
======== The End of Source Code =========
Run the program, I input:30
Then, the output is:
n=30
i=42
i<=n --> 1
It means " i(42) is smaller than n(30)". Why?
Is there any mistakes when I input a long long variable? Can you show me the right way? Thanks 开发者_Python百科for your help!First, write your main()
as
int main(void) { /* ... */ }
Or, as
int main(int argc, char *argv) { /* ... */ }
And then, probably you need a better compiler.
You should call printf("%I64d", var)
精彩评论