Help with arrays and text files

So for my homework I have to change some arrays to pointers and I've done that but I also need to allocate the memory for a one-dimensional array with data from a text file and I don't know how to do that. I have to add the number 12 to the top of this list and use that as the data.
1
2
3
4
5
6
7
8
9
10
11
12
95
100
120
130
135
145
155
185
190
160
130
120


How would I go about doing this?
So for my homework I have to change some arrays to pointers and I've done that but I also need to allocate the memory for a one-dimensional array with data from a text file and I don't know how to do that.

In other word, you do not know how to start this program?
No the program works I just don't know how to input data from a text file so I can turn it into the size of one of my arrays and I need to add that in. Sorry if I din't explain well enough.
Last edited on
closed account (48T7M4Gy)
Reading data from a text file is covered in the tutorials section of this site. Arrays are also covered, including dynamic arrays where, in this case, you could read the size of the array from the test file, create a new array dynamically and, using a for loop, which is also covered in the tutorials under control structures, procedd to read array element values from the text file into the array just created. Each has sample programs.

Write a few lines to do that and then show us your progress if you need any help.
Topic archived. No new replies allowed.