fork download
  1. #include <iostream>
  2. using namespace std;
  3. const int SIZE = 12;
  4. struct budget
  5. {
  6. float housing;
  7. float utilities;
  8. float household;
  9. float transportation;
  10. float food;
  11. float medical;
  12. float insurance;
  13. float entertainment;
  14. float clothing;
  15. float misc;
  16. };
  17. budget january[SIZE];
  18. budget getBudget();
  19. int main() {
  20. budget getBudget();
  21.  
  22. for(int i = 0; i < SIZE; i++)
  23. {
  24. cout << january[i].housing << endl;
  25. cout << january[i].utilities << endl;
  26. cout << january[i].household << endl;
  27. cout << january[i].transportation << endl;
  28. cout << january[i].food << endl;
  29. cout << january[i].medical << endl;
  30. cout << january[i].insurance << endl;
  31. cout << january[i].entertainment << endl;
  32. cout << january[i].clothing << endl;
  33. cout << january[i].misc << endl;
  34.  
  35. }
  36. return 0;
  37. }
  38.  
  39. budget getBudget()
  40. {
  41.  
  42. for(int i = 0; i < SIZE; i++)
  43. {
  44. budget temp[];
  45. cin >> temp[i].housing;
  46. cin >> temp[i].utilities;
  47. cin >> temp[i].household;
  48. cin >> temp[i].transportation;
  49. cin >> temp[i].food;
  50. cin >> temp[i].medical;
  51. cin >> temp[i].insurance;
  52. cin >> temp[i].entertainment;
  53. cin >> temp[i].clothing;
  54. cin >> temp[i].misc;
  55. }
  56. return budget temp[SIZE];
  57.  
  58. }
Compilation error #stdin compilation error #stdout 0.01s 5284KB
stdin
500.00
150.00
65.00
50.00
250.00
30.00
100.00
150.00
600.00
650.00
66.00
60.00
650.00
60.00
600.00
650.00
65.00
60.00
500.00
150.00
65.00
50.00
250.00
30.00
100.00
150.00
500.00
150.00
65.00
50.00
250.00
30.00
100.00
150.00
500.00
150.00
65.00
50.00
250.00
30.00
100.00
150.00
500.00
150.00
65.00
50.00
250.00
30.00
100.00
150.00
compilation info
prog.cpp: In function ‘budget getBudget()’:
prog.cpp:44:10: error: storage size of ‘temp’ isn’t known
   budget temp[];
          ^~~~
prog.cpp:56:15: error: expected primary-expression before ‘temp’
 return budget temp[SIZE];
               ^~~~
prog.cpp:56:14: error: expected ‘;’ before ‘temp’
 return budget temp[SIZE];
              ^~~~~
              ;
prog.cpp:56:15: error: ‘temp’ was not declared in this scope
 return budget temp[SIZE];
               ^~~~
prog.cpp:56:15: note: suggested alternative: ‘mktemp’
 return budget temp[SIZE];
               ^~~~
               mktemp
stdout
Standard output is empty