File with character and number
I ask this question before but here is another way.
I have a text file that says de3 dn4 dw5 ds8
the de, dn , dw and ds stand for the position of the door(d), and the number stand for the increment of the cursor...
i'm using ncurse for this.
so if the program reads de3, its will post a door to east side at position 3 and so on.
My question is how do i get the "de" and the number and place it to a array or pointer so i can get it to draw the door at that position
here is what i have:
i hope its more clear.
Code:
#include <stdio.h>
#include <string.h>
#include <ncurses.h>
#include <stdlib.h>
#define door '+'
int main ()
{
initscr()
FILE * pFile;
int c;
pFile=fopen ("de3.txt","r");
if (pFile==NULL) perror ("Error opening file");
else
{
c = fgetc(pFile);
while(c)
{
if( c == 'd' && c == 'e')
{
mvaddch(0, takenum[0], door); /* takenum[0] will be the number
position of the door*/
}
else
if( c == 'd' && c == 'n')
{
mvaddch(0, takenum[1], door); /* takenum[0] will be the number
position of the door*/
}
}
}
fclose (pFile);
return 0;
}