Need help with this homework :(

#include<iostream>
#include "qqq.h"
#include <string.h>
#include <math.h>
using namespace std;
void translate(char *s, char *ns);
void translate(char *s, char *ns)

{
stack<char> st;
st.push('(');
char x;
int i = -1, j = -1, n = strlen(s);
while (i < n)
{i++;
if (s[i] >= '0' && s[i] <= '9' || s[i] >= 'a' && s[i] <= 'z')
{j++;
ns[j] = s[i];
}
else
if (s[i] == '(') st.push(s[i]);
else
if (s[i] == ')')
{st.pop(x);
while (x != '(')
{j++;
ns[j] = x;
st.pop(x);
}
}
else
if (s[i] == '+' || s[i] == '-' ||
s[i] == '*' || s[i] == '/' || s[i] == '^')
{st.pop(x);
while (x != '(' && t(x) <= t(s[i]))
{j++;
ns[j] = x;
st.pop(x);
}
st.push(x);
st.push(s[i]);
}
}
st.pop(x);
while (x != '(')
{j++; ns[j] = x;
st.pop(x);
}
j++;
ns[j] = 0;
}
int t(char c)
{int p;
switch (c)
{case '+': p = 2; break;
case '-': p = 2; break;
case '*': p = 1; break;
case '/': p = 1; break;
case '^': p = 0; break;
default: p = -1;
}
return p;
}
int value(char *s);
int value(char *s)
{
stack<int> st;
int x, y, z;
unsigned int i = 0, n = strlen(s);
while (i < n)
{if (s[i] >= '0' && s[i] <= '9') st.push((int)s[i] - (int)'0');
else
if (s[i] == '+' || s[i] == '-' || s[i] == '*' || s[i] == '/' || s[i] == '^')
{st.pop(y);
st.pop(x);
switch (s[i])
{case '+': z = x+y; break;
case '-': z = x-y; break;
case '*': z = x*y; break;
case '/': z = x/y; break;
case '^': z = (int)pow(x,y);
}
st.push(z);
}
i++;
}
st.pop(z);
return z;
}
void main()
{char s[200];
cout << "s: ";
cin >> s;
char s1[200];
translate(s, s1);
cout << value(s1)<< endl;
}


The errors :
In function 'void translate(char*,char*)':
't' undeclared (first use this function)
(Each undeclared identifier is rported only once for each function it appears in.)
In function ínt t(char)':
'int t(char)' used prior to declaration
At global scope:
'main' must return 'int'
> In function 'void translate(char*,char*)':
> 't' undeclared (first use this function)
write `int t(char c);' above `void translate(char *s, char *ns)'


> 'main' must return 'int'
`int main()'
Topic archived. No new replies allowed.