I'm trying to insert commas to separate the elements in a linked list.
(1000 should read 1,000, 219038210 should read 219,038,210 etc). I've tried counting up the number of elements in the linked list and modding by 3, but it does not work. I've read many times in the case of integers converting to a string to insert the commas, but I'm not sure how to do that in a linked list.
void LList::Print(){
//PRE: The N.O. LList is valid
//POST: The N.O. LList is unchanged, and its elements have been
//displayed
Reverse();
size=1;
listnode*temp;
temp=head;
while(temp!=NULL){
size++;
if((size%3)==0)
cout<< temp->data <<"'";
else
cout<<temp->data;
temp=temp->next;
}
cout << endl <<endl;
Reverse();
}