CSCI 116
Project #10: Dynamic
Memory Allocation
Purpose: To experiment with pointers and
dynamically allocated arrays.
Assignment: You are to write a program that will get a
file name from the command line. You
should then open the file and count the number of numbers in the file (there
will be one per line). You should
allocate a dynamic array that is big enough to hold all the numbers, and then
read the numbers into the array. After
finishing reading the numbers in and closing the file, you should use linear
search to look up numbers for the user. If the user enters a negative number, your program should
exit. Here are some sample
data files: data1.txt, data2.txt, and data3.txt. Here is some sample output:
(for filename data1.txt)
Allocated
an array of 10000 numbers to hold the data
Data read in from
the file
Enter a number to
search for: 15046
15046 is in the file
Enter another
number to search for (<0 to exit): 2
2 is not in the file
Enter another
number to search for (<0 to exit): -1
Press any key to
continue…