Warning: Source file not compiled

This program ran completely fine until I added the for loop into main. It still compiles with no errors, but when I try to run it, I get a pop up window saying "Warning: Source file not compiled". I've never seen a problem like this and googleing it has not helped me. If anyone could talk me through things that cause an error like this it would be greatly appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//DISPLAY 7.12 Sorting an Array 
//Tests the procedure sort.
#include <iostream>
using namespace std;
 
void fill_array(int a[], int size, int& number_used);
//Precondition: size is the declared size of the array a.
//Postcondition: number_used is the number of values stored in a.
//a[0] through a[number_used - 1] have been filled with
//nonnegative integers read from the keyboard.

void sort(int a[], int number_used);
//Precondition: number_used <= declared size of the array a.
//The array elements a[0] through a[number_used - 1] have values.
//Postcondition: The values of a[0] through a[number_used - 1] have
//been rearranged so that a[0] <= a[1] <= ... <= a[number_used - 1].

void swap_values(int& v1, int& v2);
//Interchanges the values of v1 and v2.

int index_of_smallest(const int a[], int start_index, int number_used);
//Precondition: 0 <= start_index < number_used. Referenced array elements have 
//values.
//Returns the index i such that a[i] is the smallest of the values
//a[start_index], a[start_index + 1], ..., a[number_used - 1].


int main( )
{
    cout << "This program sorts numbers from lowest to highest.\n";
    
    int sample_array[20], number_used;
    fill_array(sample_array, 20, number_used);
    sort(sample_array, number_used);

    cout << "In sorted order the numbers are:\n";
    for (int index = 0; index < number_used; index++)
    cout << sample_array[index] << " ";
    cout << endl;
    

    cout << "The smallest number is: " << sample_array[0] << endl;
    cout << "The largest number is: "  << sample_array[number_used-1] << endl;
    
    int total = 0;
     
     for (int i = 0; i < total; i++)
    {
        total = total + sample_array[i];
    }
    
    cout << "The average is: " << total/number_used << endl;
   
    system("PAUSE");
    return 0;
}

//Uses iostream:
void fill_array(int a[], int size, int& number_used)
{
    using namespace std;
    cout << "Enter up to " << size << " nonnegative whole numbers.\n"
         << "Mark the end of the list with a negative number.\n";
    int next, index = 0;
    cin >> next;
    while ((next >= 0) && (index < size))
    {
        a[index] = next;
        index++;
        cin >> next;
    }

    number_used = index;
}
void sort(int a[], int number_used)
{
    int index_of_next_smallest;

    for (int index = 0; index < number_used - 1; index++)
    {//Place the correct value in a[index]:
        index_of_next_smallest =
                     index_of_smallest(a, index, number_used);
        swap_values(a[index], a[index_of_next_smallest]);
        //a[0] <= a[1] <=...<= a[index] are the smallest of the original array 
        //elements. The rest of the elements are in the remaining positions.
    }
}


void swap_values(int& v1, int& v2)
{
    int temp;
    temp = v1;
    v1 = v2;
    v2 = temp;
}


int index_of_smallest(const int a[], int start_index, int number_used)
{
    int min = a[start_index],
        index_of_min = start_index;
    for (int index = start_index + 1; index < number_used; index++)
        if (a[index] < min)
        {
            min = a[index];
            index_of_min = index;
            //min is the smallest of a[start_index] through a[index]
        }

    return index_of_min;
}
works fine for me. what ide are you using?
I'm sorry. I'm pretty new to this. What does ide stand for?
Integrated Development Environment. An interactive environment that allows you to edit(and compile, in most cases) your source. Examples are Code::Block, MS Visual Studio, BloodShed DevC++, Eclipse, Notepad++ e.t.c
Oh. Thank you. I'm using Dev C++.
I hope it isn't the Bloodshed version. That is an obsolete, abandoned project and it should not be recommended at all.

The correct Dev C++ is the Orwell version - this is fine, both the IDE and the compiler are maintained up to date.
http://orwelldevcpp.blogspot.co.uk/
It is the bloodshed version. That's what our instructor recommended to us, although I don't know why since you say that it is obsolete. I will switch and hopefully that will help.
closed account (3CXz8vqX)
It's been a while since I have heard of anyone using Bloodshed as far as I'm aware it hasn't had majority support for a long long time due to a lot of bugs. I haven't tried the Orwell IDE though.
The last update to the Bloodshed version was in 2005. In fact if you follow the download links to sourceforge, there are several places where it is stated: "This project has been superseded by http://sf.net/projects/orwelldevcpp/"
Topic archived. No new replies allowed.