c언어로 html파일 해석하기..
다솜
질문 제목 :c언어로 html파일 해석하기..질문 요약 :c언어로 html파일 해석하기..질문 내용 :
아래 내용을 구현하기 위해 만든 소스입니다.
#include stdio.hint main(int argc, char ** argv)
{
file * fp, * fp2;
char ch, ch2;
int cnt = 0, deep = 1;
fp = fopen(input.html, r);
fp2 = fopen(result.html, w);
if(fp == null)
{
printf(io error!\n);
exit(1);
};
ch = fgetc(fp);
//while(1)
while(1)
{
if(ch == eof)
break;
fputc(ch, fp2);
if(ch == 0x3e)
{
fputc(0x0a, fp2);
}
ch = fgetc(fp);
if(ch == 0x3c)
{
//for(cnt = 0; deep cnt; cnt++)
fputc(0x09, fp2);
//deep++;
}
}
fclose(fp);
fclose(fp2); fp = fopen(result.html, r);
if(fp == null)
{
printf(io error!\n);
exit(1);
}
ch = fgetc(fp);
while(1)
{
if(ch == eof)
return 1;
printf(%c,ch);
ch = fgetc(fp);
}
}
이렇게 만들었는데 제대로 하려면 어떻게 해야 할까요 ㅠㅠ
input.html
html
head titledata structure project/title /head
body h1html document structure/h1
아래 link를 따라가 보세요.
a href=http://portal.sjcu.ac.kr학교 홈피/a
/body
/html이 파일을 입력 받아서 아래처럼 만들고 싶습니다.
htmlheadtitle테스트/title/headbodyh1html document/h1url입니다.a href=naver.com네이버/a/body/html
-
그녀는귀여웠다
0x3c 등등은 이해하기가 힘들군요;