fork download
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. struct Student
  5. {
  6. char name[20];
  7. int id;
  8. float marks;
  9. };
  10. void display(Student s1)
  11. {
  12. cout<<s1.name<<" "<<s1.id<<" "<<" "<<s1.marks<<endl;
  13. }
  14. Student getdata(Student s1)
  15. {
  16. s1.marks=75;
  17. return s1;
  18. }
  19.  
  20. int main()
  21. {
  22. Student s1,*ptr;
  23. ptr=&s1;
  24. cin.get(s1.name,20);
  25. cin>>(*ptr).id>>ptr->marks; //s1.marks == (*ptr).marks==ptr->marks are same
  26. display(s1);
  27. s1=getdata(s1);
  28. display(s1);
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
 21906  -0.0614341
 21906  75