I’m trying to write a 2d array into an output file, it’s all working fine except in creating the .getline function to draw the array back out of the file. My issue is putting the string length. My current code for the line is;
inputFile.getline(myArray, [10][10], ‘\n’);
but it doesn’t like having the string length in square brackets it seems, what should I do?
thanks in advance
For that to compile,
myArraymust be an array ofchar, or achar*. In particular, it is a one-dimensional array. To read multiple dimensions, you’ll need to read each row separately. The second parameter tostd::istream::getlineis the maximum number ofchars to read and store in the array, minus one.To begin reading something from a file, you should start by knowing how the file was written to in the first place. You know how the file was created, I hope, but you haven’t described that in your question. Knowing how the file was written is essential for knowing how to read from it. Show some code, please.