------------------
That's how you do it, but that's just the opinion of a MADMAN!!! BWAHAHAAHAHA! :D :D :D
File I/O routines are a pain in the ***
code:// Main functionvoid main(void){ char choice=0; char x,y; char array[316]; char newline=0; CLevelDesc level; level.LoadLevelFile(); // Now get the user's input while(choice!='3') { // Now get what the heck the user wants to do printf("\nEnter 1 for reading, 2 for writing, and 3 to quit.\n"); choice=getche(); printf("\n"); switch(choice) { case '2': for(y=0; y { newline++; array[((y*CELL_X)+x)+newline-1]='\n'; printf("\n"); for(x=0; x { array[((y*CELL_X)+x)+newline-1]=getche(); } } // end for array[315]='\n'; level.WriteNewLevel(array); break; } // end switch }// end while level.UnloadFile();} // end main()
It works pretty well, except on the first line instead of getting a newline two of the lines. Here is the first line
ddddddddddddddddddddÖdddddddddddddddddddd
Could someone help me?
------------------
That's how you do it, but that's just the opinion of a MADMAN!!! BWAHAHAAHAHA!
[This message has been edited by The Madman (edited August 08, 1999).]
switch(choice)
{
case '2':
for(y=0; y{
for(x=0; x{
*array=getche();
array++;
}
*array='\r';
array++;
printf("\n");
} // end for
level.WriteNewLevel(array);
break;
} // end switch
The variable "array" is a character pointer with all the space needed allocated. Here's the class function, WriteNewLevel():
void CLevelDesc::WriteNewLevel(char *data)
{
// go to the end of the file
mmioSeek(file, 0, SEEK_END);
// Write the data to file
mmioWrite(file,data,(CELL_X+1)*(CELL_Y));
}
The problem is that my file now holds 315 letters of garbage where it should hold 320 letters of whatever I specify (right now I'm trying to use just one character that is solid throughout the file.) Could someone help me?
------------------
That's how you do it, but that's just the opinion of a MADMAN!!! BWAHAHAAHAHA! :D :D :D
Can't really see what your code is doing, because it's trying to parse it for html... look at your for loops
When you're showing code in your posts, a good suggestion is:
<code>code goes here...
</code>
White Fire