Thread: unresolved externals

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    47

    unresolved externals

    I receive 2 errors, neither of which tell me which line the error occurred:
    Code:
    Error	2	fatal error LNK1120: 1 unresolved externals
    Error	1	error LNK2019: unresolved external symbol _output referenced in function _main	blah.obj
    Since i am unsure of where or why these errors occur, my program is:

    Code:
    #include <stdio.h>
    
    void main()
    {
    
    	/*	array for shifting an uppercase letter */
    	int x[] = {3, -1, 0, 2, -2};
    
    	/*	tarray for shifting a lowercase letter */
    	int y[] = {2, 4, -1, -2};
    
    	/*	array for shifting a digit */
    	int z[] = {1, -1, 2};
    
    	int *xNext = x; 
    	int *yNext = y; 
    	int *zNext = z;
    
    	FILE *fp1, *fp2;			// file pointers
    
    	const int xArraySize = 5;
    	const int yArraySize = 4;
    	const int zArraySize = 3;
    
    	int totalChars = 0;
    	int iter = 0;
    
    	char inputTextArray[5000];
    	char inputFilename[30];		// Character Array to hold the users specified input file name
    	char currentCharacter;		//current character input from the file
    	char outputFilename[30];	// holds the users specified output file name
    	char *textArrayPointer = inputTextArray;
    
    	printf("Enter the name of the file to be scanned: "); 	
    	scanf("%s", inputFilename);			// Scans the input file specified by the user 		
    	fp1 = fopen(inputFilename, "r");	// open the file as read-only 
    
    	
    	printf("Enter the name of the file you wish to copy %s to: ",  inputFilename);	// ask user for outputFilename (copy of inputFilename)
    	scanf("%s", outputFilename);
    	fp2 = fopen(outputFilename, "w");	// open output file, write-only
    	
    
    	while((currentCharacter = getc(fp1)) != EOF)
    	{
    		*textArrayPointer = currentCharacter;
    		textArrayPointer++;
    	} 
    	
    
    
    	 while(*textArrayPointer != '\0')
    	{
    		/*	Check for capital letters A through Z
    			A in ASCII is 65, and Z is 90	*/
    		if (( *textArrayPointer >= 65 ) && ( *textArrayPointer <= 90 ))
    		{
    
    			iter = totalChars % xArraySize;
    			while(iter-- != 0)
    			{
    				xNext++;
    			}
    
    			*textArrayPointer = *textArrayPointer + *xNext;
    			if ( *textArrayPointer < 65)
    			{
    				*textArrayPointer += 26;
    				
    			}
    		
    			if ( *textArrayPointer > 90)
    			{
    				*textArrayPointer -= 26;
    			}
    
    
    			putc(inputTextArray, output(&fp2));
    		}
    
    		/*	Check for lower case letters a through z
    			a in ASCII is 97, and z is 122	*/
    		else if (( *textArrayPointer >= 97 ) && ( *textArrayPointer <= 122 ))
    		{
    
    			iter = totalChars % yArraySize;
    			while(iter-- != 0)
    			yNext++;
    		
    			*textArrayPointer = *textArrayPointer + *yNext;
    			if ( *textArrayPointer < 97)
    			{
    				*textArrayPointer += 26;
    			}
    
    			if ( *textArrayPointer > 122)
    			{
    				*textArrayPointer -= 26;
    			}
    
    			putc(inputTextArray, output(&fp2));
    		}
    
    		/*	Check for numbers 0 through 9
    			0 in ASCII is 48, and 9 is 57	*/
    		else if (( *textArrayPointer >= 48 ) && ( *textArrayPointer <= 57 ))
    		{
    
    			iter = totalChars % zArraySize;
    			while(iter-- != 0)
    			zNext++;
    
    			*textArrayPointer = *textArrayPointer + *zNext;
    			if ( *textArrayPointer < 48)
    			{
    				*textArrayPointer += 26;
    			}
    
    			if ( *textArrayPointer > 57)
    			{
    				*textArrayPointer -= 26;
    			}
    
    			putc(inputTextArray, output(&fp2));
    		}
    
    		/*	The criteria did not meet the previous
    			conditions. The character must be a symbol	*/
    		else 
    		{
    			putc(inputTextArray, output(&fp2));
    		}
    
    		*textArrayPointer++;
    		totalChars++;
    
    
    	}
    }
    What can i do to get rid of these errors?

  2. #2
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    For starters type LNK(error code) into google and find out, i'm guessing you are using visual studio, I have no idea what the error codes mean, that's why you can google it.

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    It's hard for us to know. Output is a user defined function, I'm sure, so is it located in some other source file? Are you compiling that source file?

    And as for the code...
    Don't use void main. Use int main.
    And regarding the scanf, read this: http://cboard.cprogramming.com/showp...37&postcount=9

    JFonseka:
    The error means the code is trying to call a function or use a variable that the linker could not find.
    A typical error if you don't specify the correct .lib file or fail to correctly compile and link some source files.
    It can also be that you've misnamed a function and put an invalid function prototype somewhere.

    And yes, it's Visual Studio. You can see that from the error messages
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    Quote Originally Posted by Elysia View Post
    JFonseka:
    The error means the code is trying to call a function or use a variable that the linker could not find.
    A typical error if you don't specify the correct .lib file or fail to correctly compile and link some source files.
    It can also be that you've misnamed a function and put an invalid function prototype somewhere.

    And yes, it's Visual Studio. You can see that from the error messages
    Remind me to never use visual studio then, cygwin for life

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Visual Studio beats the crap out of any other IDE I've used, and certainly Cygwin/GCC
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. Unresolved Externals
    By nickname_changed in forum C++ Programming
    Replies: 10
    Last Post: 08-31-2003, 06:13 PM
  5. debug to release modes
    By DavidP in forum Game Programming
    Replies: 5
    Last Post: 03-20-2003, 03:01 PM