| Rynomite04 (10) | |||
|
I'm supposed to write a function that will allow the user to save information into a text file (.dat i believe), however i'm having some dificulties. I have the rest of my program coded and compiling, only this function is still not working properly. I've included my code, as well as the instructions given to me in case I'm not very clear on what i'm trying to do. INSTRUCTIONS AS GIVEN TO ME: Mr. Muzik owns Fantastic Music Club that sells CDs by membership. He has four customers and would like you to create a program that will help him to keep track of the CD sales. All members of Muzik CD club must purchase an average of two CDs per year in order to qualify. An annual report is run at the end of year to help Mr. Muzik determines who haven’t fulfilled the volume requirement. ID Number of Year Number of CD bought M123 2 3 M225 1 6 M248 2 1 M552 3 5 Define a structure to store the ID, Number of Year, and Number of CD. Then, use array of structures to store all four lines of data given above. Your program will have a menu of two choices: (A) Display annual report for all customers to the screen, and (B) Write the array of structures into a text file. Put program for menu choice (A) and (B) into functions. Both functions will pass in an array of structures and the size of the array, no return value is required in both cases. Function A: The function will output a report that contains ID, Number of Year, Number of CD bought, and number of CD they still have to purchase. Function B: Output the data in the array of structures into a space delimited text file using for loop(s). Prompt the user for file name. AND HERE IS MY PROGRAM CODE WITH FAULTY TEXT FILE FUNCTION:
Thanks Again for any help that anyone is able to give me | |||
|
|
|||
| DiptenduDas (90) | |||
|
Hi, U need to fflush the stdin, before asking user input. fflush(stdin);
Hopefully this will solve ur problem. Thnx, Diptendu | |||
|
|
|||
| Rynomite04 (10) | |
| thanks, that took care of it. appreciated. | |
|
|
|