7 试题
#define MAX_BUFFER_LEN 256
int main()
{
char strBuffer[MAX_BUFFER_LEN + 1];
FILE* fileRead = NULL;
if ((fileRead = fopen("./read ", "rb")) == NULL)
{
return -1;
}
FILE* fileWrite = NULL;
if ((fileWrite = fopen("./write ", "wb")) == NULL)
{
fclose(fileRead);
return -1;
}
while (!feof(fileRead))
{
memset(strBuffer, 0, sizeof(strBuffer));
ULONG iBufferLen = fread(strBuffer, sizeof(char), MAX_BUFFER_LEN, fileRead);
string m_strBuffer = strBuffer;
ULONG m_iBufferLen = strlen(m_strBuffer.c_str());
if (m_iBufferLen > 0)
{
ULONG nWrite = fwrite(strBuffer, sizeof(char), m_iBufferLen, fileWrite);
if (nWrite == m_iBufferLen)
{
continue;
}
}
else if (m_iBufferLen == 0)
{
break;
}
fclose(fileRead);
fclose(fileWrite);
return -1;
}
fclose(fileRead);
fclose(fileWrite);
return 0;
}
下列说法一定正确的是 BD
A 文件拷贝(排除异常情况),read与write的文件内容相同
B 文件拷贝(排除异常情况),read与write的文件内容有可能不相同
C 程序中变量iBufferLen与m_iBufferLen的值相等
D 程序中变量iBufferLen与m_iBufferLen的值有可能不相等
阅读(253) | 评论(0) | 转发(0) |