0
How to dynamically allocate memory to an array to read n characters from a file?
Let's say I have the following: #include <iostream> #include <fstream> int size; char *charArray = nullptr; ifstream fin.open("strings.txt"); // More code... delete [] charArray; charArray = nullptr; How would I dynamically allocate memory to the array so that it could store any number of characters from a file, regardless of the file size? For example, if the file is 50 bytes how would I set int size to 50?
1 Antwort
0
Thanks for your answer @kurwius. it helped to point me in the right direction for what I needed. 👍