simulator calculator scientific with scrolling screen

hello.
I tried to make a simulator scientific calculator with scrolling screen.
after compiling with Code :: blocks, I get the following error which does not know the meaning.
thanks in advance

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
  /* simulator scientific calculator with scrolling screen;
the program performs the arithmetic operations, according to the priorities
arithmetic*/

#include <iostream>

using namespace std;

const int n_op =100;

struct oper
{
    float a;         // number
    char sign;       // detector of the arithmetic operator
    int prior;       // variable for the allocation of priorities, in arithmetic operations
};

struct oper calc[n_op];

int main()
{
    int conta = 0;   // counter elements and arithmetic inserted
    float result = 0;
    calc[0].prior = 3;
    calc[0].a = 0;
    cout<<" start \n: "<<result<<'\n';
    while (cin.peek() != '\n')
    {
        conta++;
        cin>>calc[conta].a>>calc[conta].sign;
    }

    for (int i=1; i<conta; i++)   // Key priority than the arithmetic operator
    {
        switch (calc[i].sign)
        {
            case '*':
                calc[i].prior = 1;
                break;

            case '/':
                calc[i].prior = 2;
                break;

            case '+':
                calc[i].prior = 3;
                break;

            case '-':
                calc[i].prior = 4;
                break;

            case '=':
                calc[i].prior = 5;
                break;

            default:
                calc[i].prior = 5;
                break;
        }
        cout<<" ";
    }

    for (int i=1; i<conta; i++)   //  cycle for the partial execution, of the arithmetic expression
    {
       switch (calc[i].prior)
          {
            case 1:
                calc[i+1].a *= calc[i].a;
                calc[i].prior = calc[i-1].prior;
                if(calc[i].prior == 4)
                  {
                   calc[i+1].a *= (-1);
                  }
                calc[i].a = 0;
                break;

            case 2:
                if(calc[i+1].a != 0)
                {
                    calc[i+1].a = calc[i].a / calc[i+1].a;
                    calc[i].prior = calc[i-1].prior;
                    if(calc[i].prior == 4)
                      {
                        calc[i+1].a *= (-1);
                      }
                    calc[i].a = 0;
                }
                else
                {
                    cout<<" error imput value. \n division for 0. \n programm terminated \n";
                    return 0;
                }
                break;
            case 3:
            break;

            case 4:
                calc[i].a *= (-1);
                break;

            default:
                break;
          }
    }
                           // cycle for the calculation of the sum of the partial operations
 float r=0;
  for (int i=1;i<=conta;i++)
    {
      r+=calc[i].a;
    }
   cout<<" the result is: "<<r<<endl; 
return 0;
}


c:\programmi\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libmingw32.a(main.o):main.c:(.text.startup+0xa7)||undefined reference to `WinMain@16'|
Last edited on
this code compiled correctly on VS2010, if it still doesn't compile on yours, maybe it's a compiler issue, though unlikely to not compile (it's just standard code).
this is a problem with linking. Check your library files both static nd dynamic, and aso check your setting.
Aceix
Last edited on
c:\programmi\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libmingw32.a(main.o):main.c:(.text.startup+0xa7)||undefined reference to `WinMain@16'|


The reference to WinMain suggests that this was set up as a Windows application. It should be a plain console application. That is, the choice of project type may be the problem.
Last edited on
@ chervil:
I think you're right.
I tried to open a new project and recompile everything. error returned.
thank you all.
Topic archived. No new replies allowed.