Hi I've made a program but for some reason I am getting this error that I can't even begin to decipher because it won't point me to where the error has been made. I am using the PV=ZnRT formula.

Here is the error:


1>C:\Users\user\Documents\Visual Studio 2008\Projects\lab24jess\Debug\lab24jess.exe : fatal error LNK1120: 1 unresolved externals


Here is my program:

#include <stdio.h>
#include <math.h>

void User_input (double *temp, double *mass, double *volume, double *Mmass, double *Pc, double *Tc);

void Cal_Z (double *T, double *m, double *v, double *Mm, double *Cp, double *Tc);

double CalculateNewZ (double Pr, double Tr);

void Print_Ans (double answer);

void main ()
{
	double temperature, kg, vol, molar, Pcrit, Tcrit, Z;

	User_input (&temperature, &kg, &vol, &molar, &Pcrit, &Tcrit);

	Cal_Z (&temperature, &kg, &vol, &molar, &Pcrit, &Tcrit);

	flushall ();
	getchar ();
}

void User_input (double *temp, double *mass, double *volume, double *Mmass, double Pc, double *Tc)
{
	printf ("Please enter the temperature in degrees Celsius: ");
	scanf ("%lf", temp);

	printf ("Please enter the mass in kg: ");
	scanf ("%lf", mass);

	printf ("Please enter the volume in M63: ");
	scanf ("%lf", volume);

	printf ("Please enter the molar mass in kg/mo: ");
	scanf ("%lf", Mmass);

	printf ("Please enter the critical pressure in kpa: ");
	scanf ("%lf", Pc);

	printf ("Please enter the critical temperature in kelvin: ");
	scanf ("%lf", Tc);

}

void Cal_Z (double *T, double *m, double *v, double *Mm, double *Cp, double *Tc)
{
	double pressure;
	double Z=1;
	double R=8.31451;
	double znew;
	double Pr=0;
	double Tr=0;
	double count;

	pressure = Z*(*m/ *Mm)*(R*(273.15+*T))/ *v;
	Pr = pressure /(*Cp);
	Tr = 286.15/(*Tc);

	znew = CalculateNewZ (Pr, Tr);

	printf ("/n		Z		Pressure	Pr		Tr		Znew");

	do
	{
		printf ("/n%0.6lf	%0.6lf	%0.6lf	%0.6lf	%0.6lf", Z, pressure, Pr, Tr, znew);

		pressure = Z*(*m/ *Mm)*(R*(273.15+*T))/ *v;
		Pr = pressure /(*Cp);
		Tr = 286.15/(*Tc);
		count = Z - znew;
		Z = znew;
		znew = CalculateNewZ (Pr, Tr);
	}
	while (count != 0);

	pressure = pressure - 92.03;

	Print_Ans (pressure);
}

double CalculateNewZ(double Pr, double Tr)
{
	/****************************************************************
     	 * Function which calculates Z using the Redlich-Kwong EOS
     	 * Refer Perry's Chemical Engineer's Handbook - 7th edition 1999
     	 * Chapter 4 - Page 4-20 and 4-21 - (Equations 4-223 and 4-224 are
     	 * where the coefficients 0.42748 and 0.08664 were obtained).
     	 * You may copy this subroutine into your programs so long
    	  * as this header is preserved in full.
     	 * Copyright (C) 2003 - J.J.Jacq
     	 ******************************************************************/

	double a = .42748 * Pr/ pow(Tr,2.5);
	double b = .08664 * Pr / Tr;
	double R1 = a - b * (1.0 + b);
	double  R2 = a * b; 
	double fz = 1.0;
	double z = 1.0;
	double dfz;

	while ( fz > 0.0001)
	{
		fz  = pow(z,3) - pow(z,2) + R1*z - R2;
		dfz = 3*(z*z) - 2*z + R1;
		z = z - fz/dfz;
		fz = abs(fz);
	}  
	
	return z;
}

void Print_Ans (double answer)
{
	printf ("/n/nThe pressure is %0.6lf kPag.", answer);
}

Edited 6 Years Ago by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

is there any more to the lnk1120 error message or was that all the compiler said? also please use code tags

Edited 6 Years Ago by NathanOliver: n/a

Ya I was trying to edit my post with code tags but i don't know how or if it's possible...

here's the complete list of warnings and error:

1>------ Build started: Project: jkl, Configuration: Debug Win32 ------
1>Compiling...
1>jkl.cpp
1>c:\users\user\documents\visual studio 2008\projects\jkl\jkl\jkl.cpp(26) : warning C4996: 'flushall': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _flushall. See online help for details.
1> d:\program files\microsoft visual studio 9.0\vc\include\stdio.h(723) : see declaration of 'flushall'
1>c:\users\user\documents\visual studio 2008\projects\jkl\jkl\jkl.cpp(20) : warning C4101: 'Z' : unreferenced local variable
1>c:\users\user\documents\visual studio 2008\projects\jkl\jkl\jkl.cpp(33) : warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> d:\program files\microsoft visual studio 9.0\vc\include\stdio.h(306) : see declaration of 'scanf'
1>c:\users\user\documents\visual studio 2008\projects\jkl\jkl\jkl.cpp(36) : warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> d:\program files\microsoft visual studio 9.0\vc\include\stdio.h(306) : see declaration of 'scanf'
1>c:\users\user\documents\visual studio 2008\projects\jkl\jkl\jkl.cpp(39) : warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> d:\program files\microsoft visual studio 9.0\vc\include\stdio.h(306) : see declaration of 'scanf'
1>c:\users\user\documents\visual studio 2008\projects\jkl\jkl\jkl.cpp(42) : warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> d:\program files\microsoft visual studio 9.0\vc\include\stdio.h(306) : see declaration of 'scanf'
1>c:\users\user\documents\visual studio 2008\projects\jkl\jkl\jkl.cpp(45) : warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> d:\program files\microsoft visual studio 9.0\vc\include\stdio.h(306) : see declaration of 'scanf'
1>c:\users\user\documents\visual studio 2008\projects\jkl\jkl\jkl.cpp(48) : warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> d:\program files\microsoft visual studio 9.0\vc\include\stdio.h(306) : see declaration of 'scanf'
1>Compiling manifest to resources...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>Linking...
1>jkl.obj : error LNK2019: unresolved external symbol "void __cdecl User_input(double *,double *,double *,double *,double *,double *)" (?User_input@@YAXPAN00000@Z) referenced in function _main
1>C:\Users\user\Documents\Visual Studio 2008\Projects\jkl\Debug\jkl.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Users\user\Documents\Visual Studio 2008\Projects\jkl\jkl\Debug\BuildLog.htm"
1>jkl - 2 error(s), 8 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Line 4 and 16 User_input is declared and used as accepting all double * parameters but

Line 24 void User_input (double *temp, double *mass, double *volume, double *Mmass, double Pc, double *Tc) the 5th parameter Pc is declare double not double *

Edited 6 Years Ago by Banfa: n/a

I have fixed the pointer in my function however it is not properly calculating the Z...it should calculate until there is a repeatable Z, however it is not doing that...

This article has been dead for over six months. Start a new discussion instead.