Thread: Storing Dice Score, help!

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    4

    Red face Storing Dice Score, help!

    Hi, I been trying to get my head around storing data from the command line to a file, but really cant get my head round this, havent really done c before and learning it slowly but as fast as I can.. PLEASE IF YOU COULD GIVE ME A HAND ON HOW I CAN PRODUCE WHAT IS REQUIRED OR GIVE ME A CLUE ON HOW I COULD TACKLE VARIOUS PARTS EG.USING AN IF STATEMENT ETC.. ON THE QUOTE UNDERNEATH WOULD BE VERY GREATFUL..


    The programs demonstrate the use of low-level file handling system calls. You must write a set of programs which provide a scoring facility for a game of darts. The first player to reach a score of exactly 250 will be deemed the winner. The program should support 5 players (though a game might involve as few as 2 players).

    The scores will be stored in a file of 5 integer numbers, each representing the score of the corresponding player. You must therefore write an initial program to create and initialize this file. This program should:

    accept the file name from the command line
    create the file with RW permissions for owner
    populate it entirely with zeroes (of which there should be 5, one for each player)
    print out the file's inode number and size in bytes once it has created it

    You must then write a program that records the scores. Note that the quality of user interface is not an important factor, so it is recommended that it is kept simple. The program should be passed the number of players for the game via the command line (acceptable range is 2 to 5). The program should allow two operations:

    a New Game can be started, which resets all scores to zero
    all current scores can be displayed
    a score can be entered
    this is wat I have up to now, please let me know also what I am doing wrong, and why? Thanks

    Code:
    #include <stdio.h>  //Allows input and output of program
    #include <io.h>     //Checks for existence of file
    
    int main(int argc, char* argv[])
    
    {
    
    fp = fopen(argv[i], "r");
    fpo = fopen(argv[i], "w");
    
       char* filename = NULL;     
    
       if( argc == 2)
           filename = argv[1];
       else
       {
           printf("Error\n");
           return 1;
       }
    
       return 0;
    }

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Well what you're doing wrong is not writing more code. Your code doesn't do anything. It doesn't open any files, doesn't read anything, etc. Try whatever it is you're stuck on, eh?

    [edit]
    I see you just decided to spam the forums instead so that someone would do your work for you.
    [/edit]


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Multiple/crossposting, (posting the same question more then once or on more then one board), is against the rules, and posting your homework questions with such a vague amount of code is in breach of the homework policy.

    As suggested, do some more work, and when you have a specific problem, you can open a new thread to deal with it.

    By the way, you are looking to write a program to store the results from a DARTS game not a dice game. First rule, always read the question.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extracting lowest and highest score from array
    By sjalesho in forum C Programming
    Replies: 6
    Last Post: 03-01-2011, 06:24 PM
  2. C program using structs to calculate grades
    By TampaTrinDM88 in forum C Programming
    Replies: 4
    Last Post: 07-06-2009, 12:33 PM
  3. Dice Simualtion
    By sillyman in forum C Programming
    Replies: 2
    Last Post: 04-22-2008, 01:43 PM
  4. trouble with creating a loop to read certain number of inputs
    By import tuner650 in forum C++ Programming
    Replies: 2
    Last Post: 03-20-2008, 07:28 PM
  5. Few errors I can't figure out
    By burn in forum C++ Programming
    Replies: 8
    Last Post: 05-07-2002, 08:43 PM