I forgot to include the programming language (It should be in the C language).
I need help in doing this program. Sample code will be greatly appreciated.
The program reads a file containing:
a. the number of integers to be sorted, followed by
b. the integers to be sorted (one integer per line) (must be the same with the indicated number of integers).
It will then be sorted out in another text file and a binary file from lowest to highest.
Other specs:
- Use dynamic memory allocation
-
The format in the terminal should be:
./program.out original-file.txt output-file.txt output-file.bin
where program.out is the program itself, original-file.txt is the text file which contains the number of integers to be sorted and the unsorted integers and the output-file.txt and output-file.bin contains the sorted integers.
Error checking:
- check if malloc() was returned successfully
the original file will look like:
3 #number of integers to be sorted
3 #the integers-separated by new line
2
1
the output file:
3
1
2
3
Thank you very much in advance 🙂 God Bless!
Just noticed the “number of integers in first string of a file” spec; I think your teacher ment you’d put them into array and sort it; but anyway do it yourself 🙂