[主观题]

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

int MyWriteFile(CString strFileName, CString strText)

{

int nRet = 0;

C.File 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;

}

参考答案与解析:

相关试题

char str[ ]= "Hello"; char *p=str; int n

[主观题]char str[ ]= "Hello";char *p=str;int n=10;sizeof(str)=( )sizeof(p)=( )sizeof(n)=( )void func(char str[100]){ }sizeof(str)=( )

  • 查看答案
  • char str[ ]= "Hello"; char *p=str; int n

    [主观题]char str[ ]= "Hello";char *p=str;int n=10;sizeof(str)=( )sizeof(p)=( )sizeof(n)=( )void func(char str[100]){ }sizeof(str)=( )

  • 查看答案
  • 请问下述代码中: int operator£«(…)起什么作用?this 是什么

    [主观题]请问下述代码中: int operator+(…)起什么作用?this 是什么?ccc 的值最终为多少?class Fruit{public:F.ruit(){weight = 2;}F.ruit(int w){weight = w;}int operator+(Fruit f){return this->weight * f.weight;}private:int weight;};F.ruit aaa;F.ruit bbb(4);int ccc = aaa + bbb;

  • 查看答案
  • 写一个函数 int strcmp(const str *str1,const s

    [主观题]写一个函数 int strcmp(const str *str1,const str *str2)要求:如果str1=str2 return 0;如果str1>str2 返回一个正数;如果 str1<str2 返回一个负数。不能调用其他函数。。。。。

  • 查看答案
  • 检查错误 int CopyStringCount(const char* Str

    [主观题]检查错误int CopyStringCount(const char* Str){int nCount = 0;char* pBuffer;pBuffer = new char[_MAX_PATH];strcpy(pBuffer,Str);for(;*pBuffer!='/0'; pBuffer++)if(*pBuffer == '/') nCount ++;// delete [] pBuffer;return nCount;}

  • 查看答案
  • 串的操作函数str定义为:int str(char*s){char*p=s;wh

    [单选题]串的操作函数str定义为: int str(char*s){ char*p=s; while(*p!=’/0')p++; return p=s; } 则str("abcde")的返回值是 ( )A.3B.4C.5D.6

  • 查看答案
  • 请把下划处的代码补充完整: ______ into student (s_nam

    [单选题]请把下划处的代码补充完整: ______ into student (s_name) ______(N’王大军’)A.update, valuesB.insert, valueC.insert, valuesD.delete, like

  • 查看答案
  • 有以下程序 #include struct NODE { int num;str

    [单选题]有以下程序 include struct NODE { int num;struct NODE*next;}; main() { struct NO有以下程序#include<stdlib.h>struct NODE{ int num;struct NODE*next;};main(){ struct NODE*p,*q,*r;p=(struct NODE*)malloc(sizeof(struct NODE));q=(struct NODE*)malloc(sizeof(struct NODE

  • 查看答案
  • 在异常处理结构中,对异常处理的代码应放在()块中。

    [填空题] 在异常处理结构中,对异常处理的代码应放在()块中。

  • 查看答案
  • 有以下程序段 typedef struct node{ int data;str

    [单选题]有以下程序段 typedef struct node{ int data;struct node *next;}*NODE; NODE p; 以下叙述中正确的是A.p是指向struct node结构变量的指针的指针B.NODE p;语句出错C.p是指向struct node结构变量的指针D.p是struct node结构变量

  • 查看答案
  • 请把下述代码加上异常处理。int MyWriteFile(CString str