Quote Originally Posted by The_Lone_Wolf
How do you populate a file with with five zeros going vertically? and

How do you print out the file's inode number and size in bytes one the above has been created?

for (i=5; i<scores; i++)
write(fd, &scores, sizeof (int));
By using the write function (and open) below, you are actually not using standard C functions, though they will be widely implemented.

Anyway, your code has issues:

- if you want to do 5 zeroes, why are you trying to write the value of "scores"?
- Why is it in the for loop? Try:
Code:
for (i = 0; i < 5; i++)
- I assume you want to create a text file, and have the scores human readable, in which case you could either use fprintf, or use write() to send a string that's been built with something like snprintf().


also how do i do the i node number i have no idea about this?
Standard C has no concept of inodes. Look up the posix functions stat and fstat.


Code:
#include<stdio.h>
#include<string.h>
#include<errno.h>

int main (int argc, char *argv[])

     int scores;

     if (argc !=2) {
       printf("Usage: %s scores\n", argv[0]);
       exit(1);

       fd = open("scorefile", 0_RDWR | 0_CREAT, 0600);
       if (fd<0) {
	 perror("cannot open file score");
	 exit(2);
All your code here is within the if (argc != 2) block, so if there is not 1 parameter, it will print the usage and exit. If there is one parameter, it will skip the whole code you pasted and go onto whatever else there is.