Problem with function identifiers-
Hi all. I'm a mechanical engineer and new to this forum. I'm doing some refresher courses on C and am trying to figure out why my program is erroring out on me. I'd appreciate any help. The program is a basic bubble sort, but when I try to compile I get
Quote:
error C3861: 'bubblesort': identifier not found
Thanks a bunch. I'm working in Visual Studio C++ Express
Code:
// mod9_7.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#define SIZE 10
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int i, arraybub[SIZE];
printf("Enter 10 integers to sort: \n");
for(i = 0; i < SIZE; i++)
{
printf("Integer %d: \n", i+1);
scanf("%d", &arraybub[i]);
}
printf("\nArray before sort: \n");
for(i = 0; i < SIZE; i++)
printf("%d, ", arraybub[i]);
bubblesort(arraybub, SIZE);
printf("\nArray after sort: \n");
for(i = 0; i < SIZE; i++)
printf("%d, ", arraybub[i]);
return 0;
}
void bubblesort(int array[], int nitems)
{
int i, j, temp;
for (i = 0; i < nitems - 1; i++)
for (j = i + 1; j < nitems; j++)
if (array[i] > array[j]) {
temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}