Hello, all...
I have a program and what it is trying to do is read in an outside file and take the 3 numbers in the files to read into row, columns, and colors. So it's something like 2 G B... 2 for the row, G for the column and B for black (there is black and white).
I have all my functions working properly, I think. But the problem I am having is with my main statement and calling the functions properly. I've been fiddling around with/trying to get this part to work for about 2 hours and I'm just getting really frustrated, so I figured maybe I can get some help.
so here is what I got so far...
Code:
#include<stdio.h>
#define sentinel 100 X X
void drawVert(char lastcol);
void drawToStone(char curcol, char stonecol);
void drawStone(char stonecol, char lastcol, char color);
void drawRestOfRow(char curcol, char lastcol);
void drawEmptyRow(char lastcol);
int main(void)
{
FILE* myin;
char column;
char lastcol='H';
char curcol='A';
char stonecol;
int stonerow;
int currow;
char color;
myin=fopen("fewstones.txt","r");
fscanf(myin, "%d %c %c", &stonerow, &stonecol, &color);
for (currow=1; currow<=8; currow++)
{
if (currow != stonerow || curcol != stonecol)
drawEmptyRow(lastcol);
if (currow != 8)
drawVert(lastcol);
else
{
while (stonerow == currow)
{
drawToStone(curcol,lastcol);
drawStone(stonecol,lastcol,color);
}
if (curcol !=lastcol)
drawRestOfRow(curcol, lastcol);
curcol = stonecol + 1;
fscanf(myin, "%d %c %c", &stonerow, &stonecol, &color);
}
}
return(0);
}
void drawVert(char lastcol)
{
char column='A';
for(column='A'; column<=lastcol; column++)
printf("| ");
printf("\n");
for(column='A'; column<=lastcol; column++)
printf("| ");
printf("\n");
}
void drawToStone(char curcol, char stonecol)
{
for(curcol; curcol<stonecol; curcol++)
{
if(curcol == 'A')
printf("---");
else if(curcol == 'H')
printf("--");
else
printf("----");
}
}
void drawStone(char stonecol, char lastcol, char color)
{
if(stonecol == 'A')
printf("%c%c-", color, color);
else if(stonecol == lastcol)
printf("%c%c", color, color);
else
printf("%c%c%c-", color, color, color);
}
void drawRestOfRow(char curcol, char lastcol)
{
for(curcol; curcol<lastcol; curcol++)
{
printf("----");
}
if(curcol==lastcol)
printf("--");
}
void drawEmptyRow(char lastcol)
{
char column;
for(column='A'; column<lastcol; column++)
printf("----");
printf("-\n");
}
If someone can help me out and steer me in the right direction, or tell me even if I am going in the right direction that would be great!! If you want to know what the program is exactly doing, I put it briefly, I can explain more...... At this point I have lost hope and am just outright confused..... Please show me the light... thank you.
-Ricky