1 Attachment(s)
Get character from a word with number
Heyy guys,
i'm new here,
im trying to fix a problem but cant find a way to do it...its only works with the first letter.
so i have a txt file with information such as de3 dn5 dn7 dw9 ds1
and im trying to figure out how to get the letters and then the number
exemple:
if de
print this is de;
and print the number that follow de
thanks.
i'll post the code that i have
Code:
#include <stdlib.h>
int main ()
{
FILE * pFile;
int c;
pFile=fopen ("de3.txt","r");
if (pFile==NULL) perror ("Error opening file");
else
{
c = fgetc(pFile);
while(c)
{
if(isdigit(c))
{
printf("the digit is %d", c);
}
if( c == 'd' && c == 'e')
{
printf("its on east");
}
else
if( c == 'd' && c == 'n')
{
printf("its on north");
}
}
}
fclose (pFile);
return 0;
}