Thread: c programming help needed!

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    1

    Question c programming help needed!

    I'm trying to write a program but I can't figure out how to do it. Maybe someone can help me out.
    Here are the specs for my program:
    __________________________________________________ _____________________
    I am writing a program for inputting and storing inventory prices. This program will assume there are 5 different inventory items: Bread, Milk, Eggs, Cheese, and Bacon. These items must be initialized as strings using an array of pointers. The program should also have an array of 5 floating point variables to store the prices of the items.

    1) When writing the code, I want to print each item, one by one, and request that the user input the price for that item.

    2) Store the user price input in the array of floating point variables.

    3) Write a function called Store_Prices that is passes both the array of inventory item names and the array of prices. This function should open a disk file called “data.txt”, and write the inventory price data as:

    Bread 1.50
    Milk 2.00



    4) Call the “Store_Prices” function to store the prices to disk.



    __________________________________________________ ___________________

  2. #2
    .........
    Join Date
    Nov 2002
    Posts
    303
    Post what you have so far.

  3. #3
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    What is it that you have problems with?

  4. #4
    1.b4 e5 2.a3 d5 3.d4 exd
    Join Date
    Jan 2003
    Posts
    167
    Although I suspect the above is homework and (while personally I dont care) I know you people dont like doing others homework, as a fellow neophyte I too am interested in how to do the above problem. I don't know how to do pointers and perhaps one of you could use that example to write a simple "intro to pointers" tutorial.
    AIM: MarderIII

  5. #5
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    There are a lot of tutorials on pointers. Google for "c pointers tutorial".

    http://pw1.netcom.com/~tjensen/ptr/pointers.htm

  6. #6
    1.b4 e5 2.a3 d5 3.d4 exd
    Join Date
    Jan 2003
    Posts
    167
    but there aren't a lot of tutorials on iniatilizing something as a string using a pointer
    AIM: MarderIII

  7. #7
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    Initialising something as a string, you mean something like this?

    char *string = "a string";

    Another site about pointers.
    http://www.function-pointer.org/

  8. #8
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231

    Re: c programming help needed!

    >>These items must be initialized as strings using an array of pointers.<<
    OK, I'm bored, so here's a single line of help for you:
    Code:
    char *Inventory[] = {"Bread", "Milk", "Eggs", "Cheese", "Bacon"};
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. free needed or not?
    By quantt in forum Linux Programming
    Replies: 3
    Last Post: 06-25-2009, 09:32 AM
  2. C Programmers needed for Direct Hire positions
    By canefan in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 09-24-2008, 11:55 AM
  3. lock needed in this scenario?
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-25-2008, 07:22 AM
  4. C++ help needed
    By Enkindu in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 08-31-2004, 11:24 PM
  5. semi-colon - where is it needed
    By kes103 in forum C++ Programming
    Replies: 8
    Last Post: 09-12-2003, 05:24 PM