fork(1) download
  1. #include <iostream>
  2. #include <assert.h>
  3. #include <typeinfo>
  4. #include "stdio.h"
  5.  
  6. using namespace std;
  7.  
  8. struct cheese
  9. {
  10. string name;
  11. float weight;
  12. float calories;
  13. float protein;
  14. float fat;
  15. float carbohydrates;
  16. };
  17. cheese D1;
  18.  
  19. D1.name = "AmericanCheese";
  20. D1.weight = 0.4;
  21. D1.calories = 375;
  22. D1.protein = 5;
  23. D1.fat = 8;
  24. D1.carbohydrates = 0;
  25. return 0;
  26.  
  27.  
  28. int dairy(int weight, struct* cheese)
  29. {
  30. return 0;
  31. }
  32.  
  33. int main(){
  34.  
  35. int weight = 0.4;
  36. cout<<"Enter weight\n"<<endl;
  37. cin>>weight;
  38.  
  39. cout<<dairy(weight,cheese)<<endl;
  40. }
  41.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:19:1: error: unknown type name 'D1'
D1.name = "AmericanCheese";
^
prog.cpp:19:3: error: cannot use dot operator on a type
D1.name = "AmericanCheese";
  ^
prog.cpp:20:1: error: unknown type name 'D1'
D1.weight = 0.4;
^
prog.cpp:20:3: error: cannot use dot operator on a type
D1.weight = 0.4;
  ^
prog.cpp:21:1: error: unknown type name 'D1'
D1.calories = 375;
^
prog.cpp:21:3: error: cannot use dot operator on a type
D1.calories = 375;
  ^
prog.cpp:22:1: error: unknown type name 'D1'
D1.protein = 5;
^
prog.cpp:22:3: error: cannot use dot operator on a type
D1.protein = 5;
  ^
prog.cpp:23:1: error: unknown type name 'D1'
D1.fat = 8;
^
prog.cpp:23:3: error: cannot use dot operator on a type
D1.fat = 8;
  ^
prog.cpp:24:1: error: unknown type name 'D1'
D1.carbohydrates = 0;
^
prog.cpp:24:3: error: cannot use dot operator on a type
D1.carbohydrates = 0;
  ^
prog.cpp:25:1: error: expected unqualified-id
return 0;
^
prog.cpp:28:23: error: declaration of anonymous struct must be a definition
int dairy(int weight, struct* cheese)
                      ^
prog.cpp:28:23: error: expected parameter declarator
prog.cpp:35:14: warning: implicit conversion from 'double' to 'int' changes value from 0.4 to 0 [-Wliteral-conversion]
int weight = 0.4;
    ~~~~~~   ^~~
prog.cpp:39:20: error: 'cheese' does not refer to a value
cout<<dairy(weight,cheese)<<endl;       
                   ^
prog.cpp:8:8: note: declared here
struct cheese
       ^
1 warning and 16 errors generated.
stdout
Standard output is empty