[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: regarding file size



Hi Ramesh,


rk> I have a file with only 3 characters say 123.when I
rk> give command ls -l it is shown as file is of size 4 bytes.

It is quite possible that you typed in an enter before you closed the
file via a CTRL-C, which would account for the fourth
character(assuming you did a cat > foo)

here is a sure way to test this, use the C program below :

#include <stdio.h>
main()
{
  FILE *fp;

  fp = fopen("foo", "wt");

  fputc('1', fp);
  fputc('2', fp);
  fputc('3', fp);

  fclose(fp);
}

Now compile, link and run this program. This will create a file foo
which has three characters 123 in it. The filesize will be 3 bytes.

You might want to see the position of the prompt when you do a cat
foo (or your file). If the prompt goes to the next line, there is an
embedded newline. In the case of foo you'll notice the prompt stays
right after the 123.

hth
BGa


---
Send e-mail to 'ilugc-request@xxxxxxxxxxxxxxxxxx' with 'unsubscribe' 
in either the subject or the body to unsubscribe from this list.