Language: C++

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <string>
#include <complex>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)
#define mp(a,b) make_pair(a, b)

typedef vector<int> vi;
typedef long long ll;
typedef complex<int> C;

char eq[128];
int index;
bool of;

C number();
C eval1();
C eval2();
C eval3();
C eval();

void check(C v) {
	if(abs(v.real()) > 10000 || abs(v.imag()) > 10000) {
		of = true;
	}
}

C number() {
	if(eq[index] == 'i') {
		index++;
		return C(0, 1);
	}

	int value = 0;
	while(isdigit(eq[index])) {
		value = value * 10 + (eq[index] - '0');
		index++;
	}
	return C(value, 0);
}

C eval3() {
	if(eq[index] == '(') {
		index++;
		C value = eval1();
	
		if(eq[index] == ')') {
			index++;
			return value;
		}
	}
	else {
		return number();
	}
	cout << "Error" << endl;
	return C(0, 0);
}

C eval2() {
	C value = eval3();
	for(;;) {
		if(eq[index] == '*') {
			index++;
			value *= eval3();
		}
		else {
			break;
		}
	}
	return value;
}

C eval1() {
	C value = eval2();
	for(;;) {
		if(eq[index] == '+') {
			index++;
			value += eval2();
		} 
		else if(eq[index] == '-') {
			index++;
			value -= eval2();
		}
		else {
			break;
		}
	}
	check(value);
	return value;
}

C eval() {
	index = 0;
	of = false;
	return eval1();
}

void print(C v) {
	if(of) {
		printf("overflow\n");
		return;
	}

	if(v.real() == 0 && v.imag() == 0) {
		printf("0\n");
		return;
	}

	if(v.real() != 0 && v.imag() == 0) {
		printf("%d\n", v.real());
		return;
	}

	if(v.real() == 0 && v.imag() != 0) {
		printf("%di\n", v.imag());
		return;
	}

	if(v.imag() > 0) {
		printf("%d+%di\n", v.real(), v.imag());
		return;
	}

	if(v.imag() < 0) {
		printf("%d%di\n", v.real(), v.imag());
		return;
	}

	cout << "unknown expression" << endl;
}

int main() {
	while(scanf("%s", eq)!=EOF) {
		C value = eval();
		print(value);
	}
}

Compiler output:
a.cc:29:5: error: 'int index' redeclared as different kind of entity
   29 | int index;
      |     ^~~~~
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from a.cc:7:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'C number()':
a.cc:45:14: error: invalid types 'char [128][<unresolved overloaded function type>]' for array subscript
   45 |         if(eq[index] == 'i') {
      |              ^
a.cc:46:22: error: no post-increment operator for type
   46 |                 index++;
      |                      ^~
a.cc:51:25: error: invalid types 'char [128][<unresolved overloaded function type>]' for array subscript
   51 |         while(isdigit(eq[index])) {
      |                         ^
a.cc:52:41: error: invalid types 'char [128][<unresolved overloaded function type>]' for array subscript
   52 |                 value = value * 10 + (eq[index] - '0');
      |                                         ^
a.cc:53:22: error: no post-increment operator for type
   53 |                 index++;
      |                      ^~
a.cc: In function 'C eval3()':
a.cc:59:14: error: invalid types 'char [128][<unresolved overloaded function type>]' for array subscript
   59 |         if(eq[index] == '(') {
      |              ^
a.cc:60:22: error: no post-increment operator for type
   60 |                 index++;
      |                      ^~
a.cc:63:22: error: invalid types 'char [128][<unresolved overloaded function type>]' for array subscript
   63 |                 if(eq[index] == ')') {
      |                      ^
a.cc:64:30: error: no post-increment operator for type
   64 |                         index++;
      |                              ^~
a.cc: In function 'C eval2()':
a.cc:78:22: error: invalid types 'char [128][<unresolved overloaded function type>]' for array subscript
   78 |                 if(eq[index] == '*') {
      |                      ^
a.cc:79:30: error: no post-increment operator for type
   79 |                         index++;
      |                              ^~
a.cc: In function 'C eval1()':
a.cc:92:22: error: invalid types 'char [128][<unresolved overloaded function type>]' for array subscript
   92 |                 if(eq[index] == '+') {
      |                      ^
a.cc:93:30: error: no post-increment operator for type
   93 |                         index++;
      |                              ^~
a.cc:96:27: error: invalid types 'char [128][<unresolved overloaded function type>]' for array subscript
   96 |                 else if(eq[index] == '-') {
      |                           ^
a.cc:97:30: error: no post-increment operator for type
   97 |                         index++;
      |                              ^~
a.cc: In function 'C eval()':
a.cc:109:17: error: overloaded function with no contextual type information
  109 |         index = 0;
      |                 ^