Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 131,718 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,348 people online right now. Registration is fast and FREE... Join Now!




Writing to a File in C

 
Reply to this topicStart new topic

Writing to a File in C

Tiger
post 25 Nov, 2005 - 05:33 AM
Post #1


New D.I.C Head

*
Joined: 9 Nov, 2005
Posts: 4


My Contributions


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?

This is the first stage of a darts program. The first file would contain zero's 5 of them becasue there are 5 players. The thing is, I don't know how to do it. below is my tried attempt sort of:

for (i = 0; i < 5; i++)
fprintf(f,"%d\n",scores);

also how do i do the i node number i have no idea about this?

the rest of my coding which so far does, accepts the filename from command line and create the file with read and write for owner.

CODE


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

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

   int Scores[5];
   ReadScores("scores.txt",Scores,5);

    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);
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/20/08 09:58AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month