Why do I get -1 when I print the following?
unsigned long long int largestIntegerInC = 18446744073709551615LL;
printf ("largestIntegerInC = %d\n", largestIntegerInC);
I know I should use llu instead of d, but why do ... |
i have this code (im working with big files support in ansi c)
unsigned long int tmp,final
final=1231123123123213
tmp=final;
printf("%llu %llu \n",final,tmp);
printf("%llu \n ",tmp);
it prints ... |
Possible Duplicate:
How to printf “unsigned long” in C?
I have my number like so...
int unsigned long number = 600851475143;
I am trying to print it ... |
Well, the title is actually the full question, is it possible to print (to stdout, or a file) an Integer (int, float, double, long, ...) without actually using any of the ... |
Alright i know this question might some weird , but still i wanted to demystify it.
1.)an int type in C can stores number in the range of -2147483648 to 2147483647.
2.)If we ... |
Is it possible to Convert Int to Hexdecimal without using 'printf'?
Best if the all the value are placed in the variable itself and some sample code with explanation.
|
It's undefined behaviour, anything can happen. However with the post and pre increment and decrement operators no guarantee is provided about when the increment or decrement is done. Only about what value will be used for the expression of the operator. i.e. ++i guarantees that the value will be the value produced by adding 1 to i but does not guarantee ... |
|
In article <7315e312-e8ca-4f52-8810-360fb5a46e6c@l32g2000hse.googlegroups.com>, Nikhil Bokare #include >int main() >{ > int a[3][3][3]; > printf("%d %d %d %d",a,*a,**a,&a); >} >I tried the above code and got the same value for a, *a , **a and &a. >Can anyone please tell me the reason behind such a behavior? You should not be printing out pointers with a %d format. A pointer might ... |
"lovecreatesbeauty@gmail.com" > #include > int main(void) { unsigned int u = 0; > u--; if (u < 0) printf("u < 0\n"); else printf("u >= 0\n"); printf("u: %d\n", u); return 0; } > $ cc a.c $ ./a.out u >= 0 u: -1 $ Because you lied to it. "%d" ... |
arindam.mukerjee@gmail.com I was running code like: #include int main() { printf("%f\n", 9/5); return 0; } and saw that the value being printed was -0.000000 (gnu) or 0.000000 (msvc6). I was expecting 2.000000. Next I tried this: #include int main() { int x = 27837; /**1**/ double f = x; printf("%f\n", x); return 0; } and the value now printed ... |
#include int main( void ) { int i = 12345; float f = 1.2345; printf( "%10d\n", i ); printf( "%9d\n", i ); printf( "%8d\n", i ); printf( "%7d\n", i ); printf( "%6d\n", i ); printf( "%5d\n", i ); printf( "%4d\n\n", i ); printf( "%10d\n", f ); printf( "%9d\n", f ); printf( "%8d\n", f ); printf( "%7d\n", f ); printf( "%6d\n", ... |
|
Hello All. I am currently working on a custom library for a project and I have having trouble with a certain function. THis function was designed to to simply take an integer and print it to the screen. e.g. print_int(int x); The problem is that since this is a custom library, I cannot use the standard I/O and can only really, ... |
edit: oh fu. my quick-and-dirty makefile was wrong, it was crashing because i was executing the asm, not a compiled binary, the clue came when i ran it with just printf("foo\n") and nothing happens. DOH!, still it works now albeit with MS format %I64u instead of %uul. any hints on making that cross platform? |
for(numargs = argc - 3; numargs > 0; numargs--) //parse the command line options, skipping that last 2 { if(!strcmp(argv[numargs], "-s")) //if the -s flag is present... { sscanf(argv[numargs + 1], "%llu", &sizeparts); //get the size of each part as an unsigned long long number from the string after the flag printf("%llu\n", sizeparts); //send it to stdout break; //found it! exit ... |
This is a poor question. You need to give more explaination/background information as to why you have this problem so that people can solve it for you properly rather than speculating about solutions and explaining some of those speculations (as NuttingCDEF did.) For better responses, please imropve your question (don't post improvements as solutions!) |