A
Andrew
I have created a program that downloads a web page and then performs
some text processing on it . The problem is in the text processing ,
every line (in the downloaded txt file ) ends with a strange symbol
which is the carriage return and the line feed . ( Hex values 0D and
0A ). How are these values represented in C ??? . For istance for
every character I read from the file i want the function to ignore it
.. for example :
....................................................
while((c=fgetc(fp) ) != EOF )
{
switch(c)
{
case '<' :
{
tagFlag=true;
cont=true;
i=0;
if(getvalue==1)
{
getvalue=0;
string_found=false ;
}
break;
}
case '>' :
{
tagFlag=false;
break;
}
case <<<<<< What should i put here ??????
{
break;
}
default :
{
if( (string_found == true) )
{
if(tagFlag == false )
{
getvalue=1;
printf("%c \n",c);
}
}
else if( (string_found==false))
{
if( (tagFlag==false) &&
(cont==true))
{
if(c==target)
{
if(i==
(target.GetLen()-1) )
{
times_found++;
string_found=true;
}
else
{
i++;
cont=true;
}
}
}
}
break;
}
}
}
..................................................
The file is stored like this :
......................................
if(ret == SOCKET_ERROR)
{
exit(EXIT_FAILURE);
}
_setmode(_fileno(fp), _O_TEXT);
/* fp is the file pointer */
do
{
bytesRead = recv(itsSocket, Buffer,
sizeof(Buffer), 0);
fwrite(Buffer,sizeof(char),bytesRead,fp);
} while(bytesRead!=0)
(Ok I know socket programming is offtopic but my question isn't ....
)
some text processing on it . The problem is in the text processing ,
every line (in the downloaded txt file ) ends with a strange symbol
which is the carriage return and the line feed . ( Hex values 0D and
0A ). How are these values represented in C ??? . For istance for
every character I read from the file i want the function to ignore it
.. for example :
....................................................
while((c=fgetc(fp) ) != EOF )
{
switch(c)
{
case '<' :
{
tagFlag=true;
cont=true;
i=0;
if(getvalue==1)
{
getvalue=0;
string_found=false ;
}
break;
}
case '>' :
{
tagFlag=false;
break;
}
case <<<<<< What should i put here ??????
{
break;
}
default :
{
if( (string_found == true) )
{
if(tagFlag == false )
{
getvalue=1;
printf("%c \n",c);
}
}
else if( (string_found==false))
{
if( (tagFlag==false) &&
(cont==true))
{
if(c==target)
{
if(i==
(target.GetLen()-1) )
{
times_found++;
string_found=true;
}
else
{
i++;
cont=true;
}
}
}
}
break;
}
}
}
..................................................
The file is stored like this :
......................................
if(ret == SOCKET_ERROR)
{
exit(EXIT_FAILURE);
}
_setmode(_fileno(fp), _O_TEXT);
/* fp is the file pointer */
do
{
bytesRead = recv(itsSocket, Buffer,
sizeof(Buffer), 0);
fwrite(Buffer,sizeof(char),bytesRead,fp);
} while(bytesRead!=0)
(Ok I know socket programming is offtopic but my question isn't ....
)