Ok I have been trying to figure this out for 3 hours and I have search a bunch of stack overflow questions and answers but I have this same error:
/usr/bin/ld: /tmp/ccXbXNRV.o: in function 'main':
main.c:(.text+0x5a): undefined reference to 'plus'
/usr/bin/ld: main.c:(.text+0x67): undefined reference to `minus'
collect2: error: ld returned 1 exit status
And I cant figure this out because my code doesn't seem that he is the problem
main.c:
#include <stdio.h>
#include "funcs.c"
int main()
{
int z = 0;
int wh = 1;
while (wh == 1)
{
printf("What you want?\n1-Plus\n2-Minus\n");
scanf("%d", &z);
if (z == 1)
{
plus();
}
if (z == 2)
{
minus();
}
}
printf("The program ended\n");
return 0;
}
funcs.c
#include <stdio.h>
inline void plus(void)
{
int a = 0;
int b = 0;
printf("Pls insert a numb\n");
scanf("%d", &a);
printf("Pls insert a numb\n");
scanf("%d", &b);
a = a + b;
printf("The result is: %d\n", a);
}
inline void minus(void)
{
int a = 0;
int b = 0;
printf("Pls insert a numb\n");
scanf("%d", &a);
printf("Pls insert a numb\n");
scanf("%d", &b);
a = a - b;
printf("The result is: %d\n", a);
}
help.h
extern int a;
extern int b;
extern int z;
extern int wh;
inline void minus(void);
inline void plus(void);
I have try to compile it with this command gcc funcs.c main.c
I know that is a simple program but I really want to learn c
If you could help I would be very thankful!