fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std; //bad
  4.  
  5. struct namen{
  6. string name;
  7. namen *p_next;
  8. };
  9.  
  10. namen add_name(namen *neuer_name, namen *liste){
  11. neuer_name->p_next = liste;
  12. cout<< neuer_name->name << " " << neuer_name->p_next->name <<endl;
  13. return *neuer_name;
  14. }
  15. int main(){
  16. namen erik;
  17. erik.name = "erik";
  18. erik.p_next = NULL;
  19. namen lina;
  20. lina.name = "lina";
  21. namen mili;
  22. mili.name = "mili";
  23. namen thomas;
  24. thomas.name = "thomas";
  25. namen liste, liste2;
  26. liste = add_name(&lina, &erik);
  27. namen *p_liste = &liste;
  28. cout<< liste.name << " " <<liste.p_next->name<< endl;
  29. cin.get();
  30. liste = add_name(&thomas, &liste);
  31. liste = add_name(&mili, &liste);
  32. }
Success #stdin #stdout 0s 3480KB
stdin
Standard input is empty
stdout
lina erik
lina erik
thomas lina
mili thomas