Zelaron Gaming Forum  
Stats Arcade Portal Forum FAQ Community Calendar Today's Posts Search
Go Back   Zelaron Gaming Forum > The Zelaron Nexus > Science and Art > Tech Help

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next

 
Quicksort
Reply
Posted 2004-11-02, 04:25 PM
I almost got this program to work but I just got two errors on them I labeled the error where it is causing it on turbo C++.


#include <stdio.h>

#define MAXNUMS 2000
void quicksort (int *a, int lft_bnd, int rt_bnd);
void swap (int a[], int i, int j);
void print_arr (int a[], int nums);

main (int argc, char * argv[])
{
char filenm[20];
int dataarray [MAXNUMS];
int num_nums=0, i, eof;
FILE *fopen(), *flpt;
void print_arr (int dataarray[], int num_nums);
if (argc !=2)
{
printf ("proper invocation: pgm datafile\n");
exit(0); //call to undefined function 'exit' in function main[int, char **]
}
flpt = fopen(argv[1],"r"); //extra parameter in call to fopen() in function main[int, char **]
if (flpt == NULL)
{
printf ("Open failed, check data filename\n");
exit(1);
}
eof = fscanf(flpt, "%d", &dataarray[num_nums]);
num_nums=num_nums+1;
while (eof >0)
{
eof = fscanf(flpt, "%d", &dataarray [num_nums]);
num_nums=num_nums+1;
if (num_nums>2000)
{
printf ("too many numbers, increase array size and recompile\n");
exit (2);
}
}
num_nums=num_nums-1;
printf ("sorting %d numbers \n", num_nums);
printf ("the unsorted numbers are:");
print_arr (dataarray, num_nums);
quicksort (dataarray, 0, num_nums-1);
printf ("the sorted numbers are: ");
print_arr (dataarray, num_nums);
}
Old
Profile PM WWW Search
deadlock75 is neither ape nor machine; has so far settled for the in-betweendeadlock75 is neither ape nor machine; has so far settled for the in-between
 
deadlock75
 



 

Bookmarks

« Previous Thread | Next Thread »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules [Forum Rules]
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -6. The time now is 02:44 AM.
'Synthesis 2' vBulletin 3.x styles and 'x79' derivative
by WetWired the Unbound and Chruser
Copyright ©2002-2008 zelaron.com
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
This site is best seen with your eyes open.