I had a compiling error when coding in C on VSCode 2 on MacOS. The program is to calculate the factorial of a natural number. Here is my .cpp
#include <stdio.h>
#include <ncurses.h>
int gthua(int);
int main()
{
char c = 'N';
int N = 1;
int kq;
do {
printf("\n Nhap mot so nguyen duong: ");
scanf("%d", &N);
kq = gthua(N);
printf("\n Giai thua cua so %d la %d",N, kq);
printf("\n Ban co muon tiep tuc khong? Y/N");
c = getch();
} while (c=='y' || c=='Y');
return 0;
}
int gthua(int n) {
int kq = 1;
while (n > 1)
kq*= n--;
return kq;
}
When I tried running the code it returned this:
Undefined symbols for architecture x86_64:
"_stdscr", referenced from:
_main in 1-cabd12.o
"_wgetch", referenced from:
_main in 1-cabd12.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What should I do?