Batorder - batorder.cpp Example of a circularly-linked list...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// batorder.cpp // Example of a circularly-linked list. / // include files #include<iostream.h> #include<iomanip.h> #include"apstring.h" # // global structure, variables, and constants struct batter_node // node for linked list { apstring batter_name; batter_node *next; // link to next node }; batter_node *first; batter_node *current_batter; // pointer to current batter // function prototypes bool get_batter_name(apstring &name); void add_node(apstring &name); void do_rotation(); void delete_list(); v // beginning of main function int main() { apstring name; if(get_batter_name(name)) // prompt user for data for the node { first = new batter_node; // initialize list head first->batter_name = name; first->next = first; // initialize next node pointer to first current_batter = first; while(get_batter_name(name)) { add_node(name); } do_rotation(); // display the batters delete_list(); // free the memory used by the linked list } return 0; } // Function that gets data from user. bool get_batter_name(apstring &name) { bool keep_data = true; cout << "\nEnter batter name (Press Enter alone to stop): "; getline(cin,name); if(name == "") { keep_data = false; } return(keep_data); }
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
// Function that adds a node to the linked list.
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern