P
Profetas
I have the following code that detects a
<c>
and
</c>
#include <stdio.h>
main(int argc, char *argv[])
{
FILE* fp;
char data[4];
fp =fopen(argv[1], "r");
while (!feof(fp))
{
fgets(data ,2,fp);
if (data[0] == '<')
{
fgets(data ,4,fp);
if (strncmp(data,"c>",2)==0)
{printf("start \n");}
if (strncmp(data,"/c>",3)==0)
{printf("end \n");}
}
printf("%c",data[0]);
}
fclose (fp);
}
and I was wondering if it was possible to return a n of char
after a n chars had been read in the while loop
because this code would detect
<c>
asd
sd
as
d
asd
</c>
but it would fail to detect
asd<c>asdasd
asd
as
asd
asdasd<a</c>asd,</asd<casd
because when it read 3 char it jumps the </ is there any
way to return 2 chars?
Thanks
<c>
and
</c>
#include <stdio.h>
main(int argc, char *argv[])
{
FILE* fp;
char data[4];
fp =fopen(argv[1], "r");
while (!feof(fp))
{
fgets(data ,2,fp);
if (data[0] == '<')
{
fgets(data ,4,fp);
if (strncmp(data,"c>",2)==0)
{printf("start \n");}
if (strncmp(data,"/c>",3)==0)
{printf("end \n");}
}
printf("%c",data[0]);
}
fclose (fp);
}
and I was wondering if it was possible to return a n of char
after a n chars had been read in the while loop
because this code would detect
<c>
asd
sd
as
d
asd
</c>
but it would fail to detect
asd<c>asdasd
asd
as
asd
asdasd<a</c>asd,</asd<casd
because when it read 3 char it jumps the </ is there any
way to return 2 chars?
Thanks