Dear all,
I am trying to build a code which finds a string from an opened file ,, but in order to find it it must tokenize every line first.. here is the code segment, If any of u can help plz..
#define MAX_MSG = 100
int main (int argc, char *argv[])
{
char rdr;
int j, fd, lop1,lop2,tst;
char line[MAX_MSG], fstrg[MAX_MSG], token[MAX_MSG];
/* some code**/
fd = open(line, O_RDONLY);
/**some code*/
memset(fstrg, '\0', MAX_MSG);
lop1 = 0;
while (read(fd, &rdr, 1) == 1)
{
fstrg[lop1] = rdr;
if (rdr == '\n' || rdr == EOF)
break;
}
token = strtok(fstrg, '#');
if ( strcmp(token, line) == 0)
{
while (read(fd, &rdr, 1) == 1)
{
write(newSd, &rdr,1);
if (rdr == '#')
break;
}
break;
}