Lỗi fatal error lnk1120 1 unresolved externals c++ năm 2024

  1. lỗi trong visual studio 2010:"fatal error LNK1120: 1 unresolved externals"


  2. > Thử clean, rebuild lại xem sao
  3. > Mã:

include<stdio.h> >

include<conio.h> >

define N 50 >

void nhap_mang(int a[],int n) > { > int i; > for(i=0;i<n;i++) > { > printf("nhap phan tu thu %d: ",i+1); > scanf("%d",a[i]); > } > } > void hoanvi(int &x,int &y) > { > int t; > t=x; > x=y; > y=t; > } > void selection_sort(int a[],int n)//sap xep selection sort > { > int i,j,min; > for(i=0;i<n;i++) > { > min=i; > for(j=i+1;j<n;j++) > if(a[j]<a[min]) > min=j; > hoanvi(a[min],a[i]); > } > } > void xuat_mang(int a[],int n) > { > int i; > for(i=0;i<n;i++) > printf(" %d ",a[i]); > } > void main() > { > int a[N],n; > printf("nhap so luong phan tu cua mang: "); > scanf("%d",&n); > nhap_mang(a,n); > selection_sort(a,n); > printf(" "); > xuat_mang(a,n); > getch(); > }

code đây nè,em rebuilt rồi mà vẫn vậy à.

-
  1. > hàm nhập thiếu dấu & ở scanf

    scanf("%d",a[i]);

    -
  2. >
    Lỗi fatal error lnk1120 1 unresolved externals c++ năm 2024
    Gửi bởi vitbau1412

hàm nhập thiếu dấu & ở scanf scanf("%d",a[i]);

cảm ơn bạn,mình sữa rồi nhưng mà vẫn bị lỗi trên à

-
  1. >
    Lỗi fatal error lnk1120 1 unresolved externals c++ năm 2024
    Gửi bởi detective009

Mã:

include<stdio.h> >

include<conio.h> >

define N 50 >

void nhap_mang(int a[],int n) > { > int i; > for(i=0;i<n;i++) > { > printf("nhap phan tu thu %d: ",i+1); > scanf("%d",a[i]); > } > } > void hoanvi(int &x,int &y) > { > int t; > t=x; > x=y; > y=t; > } > void selection_sort(int a[],int n)//sap xep selection sort > { > int i,j,min; > for(i=0;i<n;i++) > { > min=i; > for(j=i+1;j<n;j++) > if(a[j]<a[min]) > min=j; > hoanvi(a[min],a[i]); > } > } > void xuat_mang(int a[],int n) > { > int i; > for(i=0;i<n;i++) > printf(" %d ",a[i]); > } > void main() > { > int a[N],n; > printf("nhap so luong phan tu cua mang: "); > scanf("%d",&n); > nhap_mang(a,n); > selection_sort(a,n); > printf(" "); > xuat_mang(a,n); > getch(); > }

code đây nè,em rebuilt rồi mà vẫn vậy à.

bạn đổi void main() thành int main, nhớ return 0 nhé, vấn đề sẽ hết ngay[IMG]images/smilies/laughing.gif[/IMG]

-
  1. > cảm ơn RyoKai nhé, chạy được rồi nhưng mà bạn giải thích rõ hơn được không? ---

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  • BB code đang Bật
  • Smilies đang Bật
  • code đang Bật
  • code is Bật
  • HTML code đang Tắt

Nội quy - Quy định

2)unresolved external symbol _MAIN_references in function_main

how to resolve these two fatal errors?

here is my code

!calculating zeros for a function

double precision function zeroin(ax,bx,f,tol)

double precision ax,bx,f,tol

double precision a,b,c,d,e,eps,fa,fb,fc,tol1,xm,p,q,r,s

double precision dabs,dsign

c

c compute eps, the relative machine precision

c

eps = 1.0d0

10 eps = eps/2.0d0

tol1 = 1.0d0 + eps

if (tol1 .gt. 1.0d0) go to 10

c

c initialization

c

a = ax

b = bx

fa = f(a)

fb = f(b)

c

c begin step

c

20 c = a

fc = fa

d = b - a

e = d

30 if (dabs(fc) .ge. dabs(fb)) go to 40

a = b

b = c

c = a

fa = fb

fb = fc

fc = fa

c

c convergence test

c

40 tol1 = 2.0d0*eps*dabs(b) + 0.5d0*tol

xm = .5*(c - b)

if (dabs(xm) .le. tol1) go to 90

if (fb .eq. 0.0d0) go to 90

c

c is bisection necessary

c

if (dabs(e) .lt. tol1) go to 70

if (dabs(fa) .le. dabs(fb)) go to 70

c

c is quadratic interpolation possible

c

if (a .ne. c) go to 50

c

c linear interpolation

c

s = fb/fa

p = 2.0d0*xm*s

q = 1.0d0 - s

go to 60

c

c inverse quadratic interpolation

c

50 q = fa/fc

r = fb/fc

s = fb/fa

p = s*(2.0d0*xm*q*(q - r) - (b - a)*(r - 1.0d0))

q = (q - 1.0d0)*(r - 1.0d0)*(s - 1.0d0)

c

c adjust signs

c

60 if (p .gt. 0.0d0) q = -q

p = dabs(p)

c

c is interpolation acceptable

c

if ((2.0d0*p) .ge. (3.0d0*xm*q - dabs(tol1*q))) go to 70

if (p .ge. dabs(0.5d0*e*q)) go to 70

e = d

d = p/q

go to 80

c

c bisection

c

70 d = xm

e = d

c

c complete step

c

80 a = b

fa = fb

if (dabs(d) .gt. tol1) b = b + d

if (dabs(d) .le. tol1) b = b + dsign(tol1, xm)

fb = f(b)

if ((fb*(fc/dabs(fc))) .gt. 0.0d0) go to 20

go to 30

c

c done

c

90 zeroin = b

return

end

real function f(x)

f=x*x-4

return

end

What is error lnk1120?

Error LNK1120 reports the number of unresolved external symbol errors in the current link. Each unresolved external symbol first gets reported by a LNK2001 or LNK2019 error. The LNK1120 message comes last, and shows the unresolved symbol error count. You don't need to fix this error.

What does lnk1120 mean?

Each unresolved external symbol first gets reported by a LNK2001 or LNK2019 error. The LNK1120 message comes last, and shows the unresolved symbol error count. You don't need to fix this error. This error goes away when you correct all of the LNK2001 and LNK2019 linker errors before it in the build output.

Why am I getting lnk2001 errors?

You should also be getting LNK2001 errors listed what is unresolved. What are those? When you created the project, you made the wrong choice of application type. When asked whether your project was a console application or a windows application or a DLL or a static library, you made the wrong chose windows application (wrong choice).

What does unresolved external errors mean?

Actually the unresolved external errors basically means that the compiler has no idea what getArea is because the function prototype is wrong (In the return type and the parameters), it doesn't really have anything to do with the function call though the call to the function is wrong also like you said.