网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

请把下述代码加上异常处理。

int MyWriteFile(CString strFileName, CString strText)

{

int nRet = 0;

CFile myFile;

myFile.Open(strFileName, CFile::modeWrite|CFile::shareExclusive|CFile::modeCreate,

NULL);

int nLen = strText.GetLength();

myFile.Write((char*)(LPCSTR)strText, nLen);

myFile.Close();

return nRet;

}


参考答案

更多 “ 请把下述代码加上异常处理。int MyWriteFile(CString strFileName, CString strText){int nRet = 0;CFile myFile;myFile.Open(strFileName, CFile::modeWrite|CFile::shareExclusive|CFile::modeCreate,NULL);int nLen = strText.GetLength();myFile.Write((char*)(LPCSTR)strText, nLen);myFile.Close();return nRet;} ” 相关考题
考题 下列代码运行时会产生()类型的异常。 int[] array = new int[4]; System.out.println(array[7]);A.ArithmeticExceptionB.ArrayIndexOutOfBoundsExceptionC.ClassCastExceptionD.NullPointerException

考题 14、在算术表达式中,下面哪一种类型转换是错误的?A.一个int 值加上一个float 值的类型为float。B.两个unsigned char 值相加的类型为int。C.一个char 值加上一个short 值的类型为int。D.一个unsigned int 值加上一个int 值的类型为int。

考题 处理Object类对象的算法代码不能用于处理下列哪种数据?()A.StringB.StringBuilderC.IntegerD.int

考题 阅读以下程序,给出运行结果 #include <iostream> #include <cstring> using namespace std; int main() { string str="I love China!"; cout << str; return 0; }

考题 要定义两个指针变量,下面代码正确的是A.int *p1,*p2;B.int *p1, int *p2;C.int* p1,p2;D.int *(p1,p2);

考题 1、下面代码能够实现交换操作的函数有()A.swap(int a,int b) { int t=a;a=b;b=t;}B.swap(int *a,int *b) {int *c;*c=*a;*a=*b;*b=*c;}C.swap(int *a,int *b) {int *c;c=a;a=b;b=c;}D.swap(int a,int b) {int c=a;a=b;b=c;}E.swap(int *a,int *b) {int c=*a;*a=*b;*b=c;}

考题 处理Object类对象的算法代码不能用于处理()类型的数据。A.StringB.StringBuilderC.IntegerD.int

考题 CString对象中有一个getBuffer()用于获取CString对象中的字符串(char *)

考题 18、下列代码运行时会产生()类型的异常。 int[] array = new int[4]; System.out.println(array[7]);A.ArithmeticExceptionB.ArrayIndexOutOfBoundsExceptionC.ClassCastExceptionD.NullPointerException