#define MAX_LENGTH 15536
#include
#include
using namespace std.
string delEnter(const string src) // 过滤掉串中的回车换行符
{
string des.
for(int i = 0. i < src.length(). i )
{
char tempChar = src[i].
if( tempChar!=10 &.&. tempChar!=13)
des.append(1,tempChar).
}
return des.
}
int main()
{
char html[MAX_LENGTH] = "".
FILE *fp = fopen("Linux.txt", "rb"). //FILE *fp = fopen("Windows.txt", "rb").
char buf[16384].
while (fgets(buf, 16384, fp))
strcat(html, buf).
strcat(html,"\0").
string s(html).
cout << "string is: " << s << endl..
cout << "The size of string is: " << s.length() << endl.
cout << "after del string is: " << delEnter(s) << endl.
cout << "The size of string is: " << delEnter(s).length() << endl.
fclose(fp).
return 0.
} |