Re: printf and stat problem
- From: Martin Ambuhl <mambuhl@xxxxxxxxxxxxx>
- Date: Sat, 14 May 2005 08:17:35 GMT
diadia wrote:
#include <sys/types.h> #include <sys/stat.h>
You have been told that these headers are non-standard. Remove anything that interfers with compiling with a standard C compiler on a platform other than yours. If this stuff were relevant, you would be in the wrong place.
#include <ctype.h> #include <stdio.h>
int estimateLen(struct stat buf, FILE *fp) {
int size = buf.st_size / 4; printf("%d %d\n",buf.st_size,size); printf("%d %d\n",size,buf.st_size); }
int main(int argc,char*argv[]) { FILE *fp; struct stat s;
if (stat(argv[argc-1],&s)) printf("stat error\n");
estimateLen(s,fp); return 0;
}
i change my code like this
sorry .... although it's not stand,thanks for replying
You really should pay attention next time. I don't know why I bothered carefully explaing your problem to you if you were going to ignore me. If buf.st_size is not an int, then you are calling printf incorrectly. Watch:
#include <ctype.h> #include <stdio.h>
struct stat
{
size_t st_size;
};void estimateLen(struct stat buf)
{ int size = buf.st_size / 4;
printf("%d %d\n", (int) buf.st_size, size); /* NOTE */
printf("%d %d\n", size, (int) buf.st_size);
}int main(void)
{
struct stat s = {.st_size = 7949 };
estimateLen(s);
return 0;} .
- Prev by Date: Re: C book recommendations
- Next by Date: Re: C book recommendations
- Previous by thread: Re: printf and stat problem
- Next by thread: function called through a non-compatible type
- Index(es):
Relevant Pages
|