如果文件中有其他的字符 只转小写字母的话 用下面的代码:
int main()
{
int size = 1024 * 1024;
char* rBuffer = new char[size];
FILE* fp = fopen("alpha.txt", "a+t");
if (fp != NULL)
{
int n= fread(rBuffer, sizeof(char), size,fp);
for (int i = 0; i < n; i++)
{
char c = rBuffer[i];
if (c >= 'a' && c <= 'z')
{
c -= 32;
fwrite(&c, sizeof(char), 1, fp);
}
}
fclose(fp);
}
delete[] rBuffer;
}