fork(1) download
  1. #include <stdio.h>
  2.  
  3. struct inventory
  4. {
  5. char name[20];
  6. int number;
  7. };
  8.  
  9. struct inventory function();
  10.  
  11. int main(void)
  12. {
  13. struct inventory items;
  14. items=function();
  15. printf("\nam in main\n");
  16. printf("\n%s\t",(items).name);
  17. printf(" %d\t",(items).number);
  18. }
  19.  
  20. struct inventory function()
  21. {
  22. struct inventory items;
  23. printf(" enter the item name\n ");
  24. scanf(" %s ",&items.name );
  25. printf(" enter the number of items\n ");
  26. scanf("%d",&items.number );
  27. return items;
  28. }
Runtime error #stdin #stdout 0s 2252KB
stdin
gitesh
24
stdout
 enter the item name
  enter the number of items
 
am in main

gitesh	 24