Compile Time Error : Local function definitions are illegal ? :|||CO

[b][red]This message was edited by BigVent at 2003-1-25 19:15:49[/red][/b][hr]
Can anyone please tell me what I am doing wrong? (I'm sure it's multiple things but I'm getting compile errors regarding functions "printout" & "main".) Any help is appreciated & Thanks in advance!
//Function program that requires an input from keyboard
//and prints all the Prime Numbers up to the inputted value.
//Project #1

using namespace std;

//get_value function, get's the inputted value from the keyboard
//for this exercise the value of size should not exceed 500.
void get_value(int size)
cout << "Please input a value: ";
cin >> size;
if (size > 500 || size < 1)
cout << "You Entered an Incorrect Value!";

//fill_array function, fills the array
//with the "size" inputted from keyboard setting
//each subscript value equal to one.
void fill_array(int arr[], int size)
int i;
for (i = 2; i < size; i++)
arr[i] = 1;

//prime function, starts with subscript #2 through the "size"
//inputted from keyboard & "if" the subscript's value is
//divisible by either a (2 - or - 3) the value of subscript
//will be set to zero... else set value is equal to one
int prime (int p_factor)
int i,p;
for (i = 2; i < p_factor; i++)

if (p % i == 0)
return 0;
return 1;

//Sieve of Eratosthenes function, takes array & size as input.
//this function starts with subscript #2 & loops through
//the array & sets to zero every element whose value
//subscript is a multiple of that subscript for the element value 1.
//array continues until it has reached the input value.
void sieve(int arr[], int size)
int i, j;
for (i = 2; i < size; i++)
if (arr[i] == 1 && prime(i))

for (j = i + 1; j < size - 1; j++)
if ( j % i == 0 && arr[i] == 1)
arr[j] = 0;
arr[i] = 0;

//printout function, prints out the index of the array
//only if the value of the subscript is equal to one.
//also only prints ten "Prime" numbers per line.
void printout(int arr[], int size)

//Project1.cpp(76) : error C2601: 'printout' : local
//function definitions are illegal
//when you click on this statement it points to here ---->
int count = 0;
for (int i = 2; i < size; i++)
if (arr[i] == 1)
cout << setw(4) << i;
count++; //bumps counter for times outputted

//purely for neatness & it was required
//to only have ten prime values printed
//per line so the above counter "j" was used.
if (count > 10)
{ cout << endl;
} }

//main function, calls on functions to complete tasks
void main ()
int size;
int arr[size + 1] = {0};

fill_array(array, size);
sieve(array, size);
printout(array, size);

//Project1.cpp(119) : fatal error C1004: unexpected end of file found


  • [b][red]This message was edited by AsmGuru62 at 2003-1-27 8:59:52[/red][/b][hr]
    [blue]Your scope operators [b]{[/b] and [b]}[/b] are messed up... If you are using VC++ hold CTRL and press }-key when caret is on the '{' or '}' - you should see the editor point to the enclosing '}' or '{'. [/blue]

This discussion has been closed.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!