Thread: unresolved external

  1. #1
    False Return hubris's Avatar
    Join Date
    Apr 2009
    Posts
    33

    Question unresolved external

    Simple enough. Been doing exercises for days to brush up for next term and this one (selectionSort func followed by sequentialSearch) keeps giving me error:
    Unresolved External...???

    Code:
    #include <iostream>
    
    using namespace std;
    
    const int A_S = 10;
    
    int seqSearch(const int list[], int listLength, int searchItem);
    void selectionSort (int list[], int length);
    
    int main()
    {
    	int list[] = {2, 56, 34, 25, 73, 46, 89, 10, 5, 16};
    	int i;
    	int index;
    	int number;
    
    	selectionSort(list, 10);
    	cout << "After sorting, the list elements are:" << endl;
    	for (i = 0; i < 10; i++)
    		cout << list[i] << " ";
    	cout << "Enter the number to be searched: ";
    	cin >> number;
    	cout << endl;
    
    	index = seqSearch(list, A_S, number);
    
    	if (index != -1)
    		cout << number << " is found at position " << index << "." << endl;
    	else
    		cout << number << " is not in the list." << endl;
    
    	return 0;
    }
    
    void selctionSort (int list[], int length)
    {
    	int index;
    	int smallestIndex;
    	int minIndex;
    	int temp;
    
    	for (index = 0; index < length - 1; index++)
    	{
    
    		smallestIndex = index;
    
    		for (minIndex = index + 1; minIndex < length; minIndex++)
    			if (list[minIndex] < list[smallestIndex])
    				smallestIndex = minIndex;
    
    		temp = list[smallestIndex];
    		list[smallestIndex] = list[index];
    		list[index] = temp;
    		
    	}
    	
    }
    
    int seqSearch(const int list[], int listLength, int searchItem)
    {
    	int loc;
    
    	bool found = false;
    
    	for (loc = 0; loc < listLength; loc++)
    		if (list[loc] == searchItem)
    		{
    			found = true;
    			break;
    		}
    
    		if (found)
    			return loc;
    		else
    			return -1;
    }
    Last edited by hubris; 03-10-2011 at 11:31 PM. Reason: sp
    Are unmarried people a kind of "Global Variable"?

  2. #2
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    Code:
    list[index] = temp;
    //Here what is the value of temp?

  3. #3
    False Return hubris's Avatar
    Join Date
    Apr 2009
    Posts
    33
    (facepalm) got it...simple typo
    ...Thank you 777.
    Last edited by hubris; 03-10-2011 at 11:49 PM. Reason: syno
    Are unmarried people a kind of "Global Variable"?

  4. #4
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    Don't mention.....
    These mistakes are common ...... Not your mistake... Every programmer does the same :-)

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You should seek to use vectors or iterators instead of pure arrays. They make your code dangerous.
    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. Testpad for itoa()
    By frktons in forum C Programming
    Replies: 92
    Last Post: 07-19-2010, 03:05 PM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  5. debug to release modes
    By DavidP in forum Game Programming
    Replies: 5
    Last Post: 03-20-2003, 03:01 PM