Hi everyone, so I'm making a program that lets the user make a crossword puzzle. I have some pseudo code for the input/output. But I don't know how to handle file for this. The puzzle itself will be stored as a 2d array of strings/chars in a separate file.
My question is, what file type should I use? How can I manipulate the array in the file? Is that even possible? I've only seen strings be stored/manipulated in files, but no more than that.
Manipulating the array in the file is not easy. I'm not quite sure I understand your statement about "The puzzle itself will be stored as a 2d array of strings/chars in a separate file." Are you trying to figure out how to write the puzzle to the file?
I mistyped, it lets the user solve a crossword puzzle I've made.
The empty puzzle is already in the file, stored as a 2d array. What I was planning to do is to open the puzzle file, and then the user will fill in the puzzle. The program will then receive a cstring, and then fill in each array element with a character from that cstring.
What I'd like to know is if I can manipulate the array like I normally would-as if it wasn't in a separate file. By manipulate, I just mean can I open the file containing the array, and go
Open the file
while( ! eof )
{
Read a line
if eof
{
break;
} // if( eof )
else
{
// Start a for-loop for all characters in this line:
for( int i = 0; i < the length of the line; i++ )
{
if( the current character is an underscore )
{
output a solid box
}
else
{
output a space
}
} // for-loop
} // if( ! eof )
} // while ! eof
In this input loop I would also store the entire puzzle in another array so you can compare the user's input to the actual puzzle solution.