C Programming Assignment

0 Samuel Egiefameh · March 12, 2015
Hey everyone, I am working on my homework assignment and the first part for me is to produce this output:

/images/forum/upload/2015-03-12/3e14bc74c965c72f192dadab8032dcd2.png

Here's my code so far:

#include<stdio.h>
#include<Windows.h>

#define HEIGHT 78
#define WIDTH 21

void ReadMap(int x, int y);

int main(void)
{
int map[HEIGHT][WIDTH];

ReadMap(WIDTH, HEIGHT);

printf("\n\n");
system("pause");
return 0;
}



void ReadMap(int x, int y)
{
char c;
FILE * fPointer;
    fPointer = fopen("map6.txt", "r");
   
do
{
c = fgetc(fPointer);
printf("%c", c);
if(c == 'X')
printf("\b%c", 255);
else
printf("\b%c", 176);
}
while(c != EOF);

return;
}

And here is my output:

Does anyone know what I may be doing wrong? As you can see, my output is somewhat close to how the assignment is supposed to look, but I cant seem to get the ASCII characters to the other side of the screen. Your help will be kindly appreciated. Thank you

/images/forum/upload/2015-03-12/135469ed9091426c7d5f1e301b128d16.png

Post a Reply

Replies

Oldest  Newest  Rating
0 Lazar Bulic · March 17, 2015
Can you provide the  map6.txt file or any other map so I can test the program?
  • 1

C

106,948 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator