I need your help with running my code.
Here it is:
`
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern "C"
{
void asmMain(void);
int asmScanf(char* dest, int maxLen);
}
int asmScanf(char* dest, int maxLen)
{
char* result = fgets(dest, maxLen, stdin);
if (result != NULL)
{
int len = strlen(result);
if (len > 0)
{
dest[len - 1] = 0;
}
return len;
}
return NULL;
}
void clrscr(void)
{
system("cls");
}
int main(void)
{
clrscr();
printf("Start asemblerskog programa: %sn");
asmMain();
printf("Kraj asemblerskog programa.n");
return 0;
}
`
`
.const
option casemap:none
NULL equ 0
noviRed equ 10
maxDuzina equ 256
.data
decBroj db "Decimalni broj: ", 0
unosBroj db "Uneseni broj u decimalnom obliku: %s", noviRed, 0
hexBroj db noviRed, "Uneseni broj u heksadecimalnom obliku: %X", noviRed, 0
unos db maxDuzina dup(?)
broj dd 0
.code
externdef printf:proc
externdef asmScanf:proc
externdef atoi:proc
externdef exit:proc
public asmMain
asmMain proc
push rbp
mov rbp, rsp
sub rsp, 8
lea rcx, decBroj
xor rdx, rdx
call printf
lea rcx, unos
lea rdx, [maxDuzina]
call asmScanf
lea rcx, unos
mov rdx, r8
call printf
lea rcx, unos
call atoi
mov dword ptr [broj], eax
mov eax, dword ptr [broj]
lea rcx, hexBroj
call printf
add rsp, 8
mov rsp, rbp
pop rbp
xor eax, eax
call exit
asmMain endp
end
`
No matter which code I have (I even tried printing Hello World), I get these errors:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol printf referenced in function asmMain
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol asmScanf referenced in function asmMain
ANY SUGGESTIONS AND SOLUTIONS ARE MORE THAN WELCOME!
I put .masm in Customize dependencies, I’ve added main in Linker and put MASM in .asm file (Properties, Item Type).. I need the solution for my problem!