assgn_st.cpp 554 B

123456789101112131415161718192021222324252627
  1. // assgn_st.cpp -- assigning structures
  2. #include <iostream>
  3. struct inflatable
  4. {
  5. char name[20];
  6. float volume;
  7. double price;
  8. };
  9. int main()
  10. {
  11. using namespace std;
  12. inflatable bouquet =
  13. {
  14. "sunflowers",
  15. 0.20,
  16. 12.49
  17. };
  18. inflatable choice;
  19. cout << "bouquet: " << bouquet.name << " for $";
  20. cout << bouquet.price << endl;
  21. choice = bouquet; // assign one structure to another
  22. cout << "choice: " << choice.name << " for $";
  23. cout << choice.price << endl;
  24. // cin.get();
  25. return 0;
  26. }