Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include "mycomm.h"
- int state=0;
- int row=0, col=0;
- FILE *f;
- char area[MAX_ROWS][MAX_COLS];
- void reset(){
- for(int i=0;i<MAX_ROWS;i++)
- for(int j=0;j<MAX_COLS;j++)
- area[i][j]=' ';
- row=0, col=0;
- }
- void writefile(){
- f=fopen(fname, "w+");
- for(int i=0;i<MAX_ROWS;i++){
- for(int j=0;j<MAX_COLS;j++)
- fputc(area[i][j], f);
- fputc('\n', f);
- }
- fclose(f);
- }
- void write(){
- if(state){
- area[row][col]=42;
- writefile();
- }
- }
- void move(int d){
- switch (d){
- case 1:col--;break;
- case 2:col++;break;
- case 3:row++;break;
- case 4:row--;break;
- default: break;
- }
- write();
- }
- void show(){
- char c;
- f=fopen(fname, "r");
- while(!feof(f)){
- c=fgetc(f);
- printf("%c", c);
- }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment