Hi Vijay,
I just tested the first one, and Mox is right (congrats for the
tip ! ): cast sb.st_size as long int is the key.
FYI, the exact code I tested is :
"""""""""""" quotes """""""""""""""""""
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
int
main(int argc, char **argv)
{
struct stat sb;
int retval;
if(argc<2){
fprintf(stderr,"Usage: %s <filename>\n", argv[0]);
exit(1);
}
retval = stat(argv[1], &sb);
if(retval==0) printf("Size of %s, uid %d, is %ld\n", argv[1],
sb.st_uid, (long)sb.st_size);
else perror("stat");
return EXIT_SUCCESS;
}
"""""""""""" end quotes """"""""""""""""
Compiled with -Wall and -ansi -> no warning, and no problem so far
ordinateur-de-eric-b:~ ericb$ gcc -Wall -ansi truc.c -o bidule
ordinateur-de-eric-b:~ ericb$ ./bidule .xinitrc
Size of .xinitrc, uid 501, is 582
Regards,
Eric
Le 28 déc. 06 à 03:04, Vijay Venkatraman a écrit :
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
main(int argc, char **argv)
{
struct stat sb;
int retval;
if(argc<2){
fprintf(stderr,"Usage: %s <filename>\n", argv[0]);
exit(1);
}
retval = stat(argv[1], &sb);
if(retval==0) printf("Size of %s, uid %d, is %d\n", argv[1],
sb.st_uid, sb.st_size);
else perror("stat");
}