Error LNK2019

I've looked but can't seem to figure out what's causing these errors:

warning C4013: 'print__complex' undefined; assuming extern returning int
error LNK2019: unresolved external symbol _print__complex referenced in function _main
fatal error LNK1120: 1 unresolved externals

Could someone take a quick look?

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
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void add_complex(float z1_r, float z1_i, float z2_r, float z2_i, float* z3_r, float* z3_i){
	*z3_r = z1_r + z2_r;
	*z3_i = z1_i + z2_i;
}
void subtract_complex(float z1_r, float z1_i, float z2_r, float z2_i, float* z3_r, float* z3_i){
	*z3_r = z1_r - z2_r;
	*z3_i = z1_i - z2_i;
}
void mul_complex(float z1_r, float z1_i, float z2_r, float z2_i, float* z3_r, float* z3_i){
	*z3_r = z1_r * z2_r;
	*z3_i = z1_i * z2_i;
}
void div_complex(float z1_r, float z1_i, float z2_r, float z2_i, float* z3_r, float* z3_i){
	*z3_r = z1_r / z2_r;
	*z3_i = z1_i / z2_i;

}
void print_complex(float z_r, float z_i){
	printf("(");
	if (z_r != 0){
		printf("%f", z_r);
	}
	if ((z_i > 0) && (z_r != 0)){
		printf("+");
	}
	if (z_i != 0){
		printf("%fi", z_i);
	}
	printf(")");
}
int main(void){
	float z1_r = 0.0;
	float z1_i = 0.0;
	float z2_r = 0.0;
	float z2_i = 0.0;
	float z3_i = 0.0;
	float z3_r = 0.0;
	char choice = '?';

	printf("Complex number calculator");
	printf("Enter 1st complex number (real and imaginary):");
	scanf("%f %f", &z1_r, &z1_i);
	printf("Enter 2nd complex number (real and imaginary): ");
	scanf("%f %f", &z2_r, &z2_i);
	printf("Press A for + , S for - , M for *, D for / :");
	scanf("%c", choice);
	switch (choice){
	case 'A': 
		print_complex(z1_r, z1_i);
		printf(" + ");
		print__complex(z2_r, z2_i);
		printf(" = ");
		add_complex(z1_r, z1_i, z2_r, z2_i, &z3_r, &z3_i);
		print_complex(z3_r, z3_i);
		break;
	case 'S': 
		print_complex(z1_r, z1_i);
		printf(" - ");
		print__complex(z2_r, z2_i);
		printf(" = ");
		subtract_complex(z1_r, z1_i, z2_r, z2_i, &z3_r, &z3_i);
		print_complex(z3_r, z3_i);
		break;
	case 'M': 
		print_complex(z1_r, z1_i);
		printf(" * ");
		print__complex(z2_r, z2_i);
		printf(" = ");
		mul_complex(z1_r, z1_i, z2_r, z2_i, &z3_r, &z3_i);
		print_complex(z3_r, z3_i);
		break;
	case 'D': 
		print_complex(z1_r, z1_i);
		printf(" / ");
		print__complex(z2_r, z2_i);
		printf(" = ");
		div_complex(z1_r, z1_i, z2_r, z2_i, &z3_r, &z3_i);
		print_complex(z3_r, z3_i);
		break;
	default:
		printf("Your choice is invalid.\n");
		break;
	}
}
This print__complex is likely a typo -> print_complex
Yip that was it, wow thanks!
Topic archived. No new replies allowed.