![]() |
creditcard structures in C
Heres what i need to do!!
A. Create a structure, called creditcard that contains three members: credit_card_number (integer data type), authorization_number (integer data type) and amount_to_charge (float data type): B. Create an array called records, which contains 50 creditcard structures. C. Using three lines of code, initialize the data for records[25] to: credit_card_number = 4111111, authorization_number=56222 and amount_to_charge = 29.95. D. Create a pointer to creditcard and call it cardPtr. Initialize cardPtr to point to the zeroeth element of the records array. E. Using cardPtr defined above, initialize the data for records[0] to: credit_card_number=599121, authorization_number = 89333 and amount_to_charge = 49.95. F. Using cardPtr, print out all data contained in records[25]. Heres what i have, please help!! i ran the program, it compiles and runs fine, but the problem is, it prints out two lines of text saying only credit card number, and give random numbers each time the program is run. Code:
|
Re: creditcard structures in C
sorry i put the wrong code up there, heres the right code.
Code:
|
Re: creditcard structures in C
I'm confused by the assignment directives, but I think they are getting at pointer dereferencing. ccPtr can point to any element in records. Once assigned to a record, you dereference elements using the -> operator.
Try something like this: Code:
#include <stdio.h> |
| All times are GMT +5.5. The time now is 10:32. |