一些基础:VC编程经验和错误[3]

[入库:2005年8月19日] [更新:2007年3月24日]

本文简介:选择自 rainee 的 blog

易发生错误一:

sscanf(buf, text(“%d”), var);           //遗忘”&”

sscanf(buf, text(“%d”), &var);

易发生错误二:

template<class t> class mytem操作时,如果在头文件中仅仅声明class myclass,那么如下操作导致:

mytem<myclass> m_mytem;

可能出错。已遇上的错误:myclass中使用virtualalloc分配内存时,sizeof(myclass)的值不确定,导致分配内存失败。

关于combobox的使用:

combobox有dropdown和droplist两种type,对于droplist来说,onselchange()中使用updatedata()可以获得用户选择的项,而对于dropdown来说,onselchange()中必须先使用m_ctrlcombo.setsel(m_ctrlcombo.getsel()),然后使用updatedata()才可以获取用户选择的项。

要善于使用she处理问题,如记录文件读取:

file* pfile = fopen(strfilename, “r”);

do

{

    __try

{

        fgets(czbuf, linenum, pfile);

        //do your things here…

 

    }

    __except(exception_execute_handler)

{

    //continue or break?

}

}while(!feof(pfile));

fclose(pfile);

 

本文关键:一些基础:VC编程经验和错误
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top