Like Tree5Likes
  • 1 Post By Lesshardtofind
  • 1 Post By c99tutorial
  • 2 Post By Adak
  • 1 Post By Crossfire

Product inventory file??

This is a discussion on Product inventory file?? within the C Programming forums, part of the General Programming Boards category; Hello, How to make a program in C to create a product inventory file containing pro0duct name, cost and quantitity ...

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    54

    Angry Product inventory file??

    Hello,

    How to make a program in C to create a product inventory file containing pro0duct name, cost and quantitity and then read the prouct inventory file.

    ?


  2. #2
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    407
    I always love when the demand for work is done with an angry face! Makes me laugh everytime.

  3. #3
    Registered User
    Join Date
    Nov 2012
    Posts
    1,053
    Code:
    int main(void) {
        // Write inventory file
        FILE *f = fopen("inventory.dat", "w");
        if (f == NULL)
            return(EXIT_FAILURE);
        fprintf(f, "%s\n", "pro0duct name");
        fprintf(f, "%s\n", "cost");
        fprintf(f, "%s\n", "quantitity");
        if (fclose(f) == EOF)
            return(EXIT_FAILURE);    
        printf("Inventory file successfully written.\n");
        
        // Read inventory file
        char buf[1000];
        FILE *g = fopen("inventory.dat", "r");
        if (g == NULL)
            return(EXIT_FAILURE);
        printf("Reading inventory file:\n");
        while (fgets(buf, 1000, g) != NULL) {
            printf("%s", buf);
        }
        if (fclose(g) == EOF)
            exit(EXIT_FAILURE);
        printf("Inventory file successfully read.\n");
        return EXIT_SUCCESS;
    }

  4. #4
    Registered User
    Join Date
    Nov 2012
    Posts
    54
    error: undefined symbol EXIT_SUCCESS, EXIT_FAILURE

  5. #5

  6. #6
    Registered User
    Join Date
    Nov 2012
    Posts
    54
    ok... please write the input "piece" of code where the user write data with respect to product name, cost, quantity etc and it save in the file inventory.dat

  7. #7
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by shansajid View Post
    ok... please write the input "piece" of code where the user write data with respect to product name, cost, quantity etc and it save in the file inventory.dat
    No. That's not what we do. YOU need to start your program, THEN if you run into trouble with it, YOU need to post your code up, and describe what that trouble is, in detail. THEN we will help you get that worked out.

    We are not a short order coding service!
    Salem and Crossfire like this.

  8. #8
    Registered User
    Join Date
    Dec 2012
    Posts
    289
    i LOVE how after you post this....

    Quote Originally Posted by Lesshardtofind View Post
    I always love when the demand for work is done with an angry face! Makes me laugh everytime.
    he responds with

    Quote Originally Posted by shansajid View Post
    ok... please write the input "piece" of code where the user write data with respect to product name, cost, quantity etc and it save in the file inventory.dat
    i hope THIS GUY works for me someday!!! i would have a blast with him...then of course fire him!

    HEY shansajid, how long till you graduate? (stupid question i know, he will be a drop out soon!!!)
    Salem likes this.

  9. #9
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Yeah, he wins the blatant "do it for me, sucker!" post for this month. LOL!

  10. #10
    Registered User
    Join Date
    Nov 2012
    Posts
    54
    no problem......................

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Product Keys
    By codegirl in forum Tech Board
    Replies: 6
    Last Post: 05-20-2006, 02:55 PM
  2. Console Text RPG- File I/O and Inventory
    By Jontay in forum Game Programming
    Replies: 17
    Last Post: 11-23-2003, 01:37 AM
  3. List inventory file to screen
    By romeoz in forum C++ Programming
    Replies: 6
    Last Post: 09-18-2003, 09:03 AM
  4. Dot Product.......Help
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 03-07-2003, 07:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21