if(stricmp(ext,".doc")==0)
return 1;
else if(stricmp(ext,".xls")==0)
return 2;
else if(stricmp(ext,".dwg")==0)
return 3;
else if(stricmp(ext,".psd")==0)
return 4;
else if(stricmp(ext,".pdf")==0)
return 5;
else if(stricmp(ext,".txt")==0)
{
// m_listCtrl.InsertItem(0,"txt");
return 6;
}
else
return 0;
如果上面的被注释的语句没有注释掉,则返回值正常
否则当ext=".txt"时返回0……
return 1;
else if(stricmp(ext,".xls")==0)
return 2;
else if(stricmp(ext,".dwg")==0)
return 3;
else if(stricmp(ext,".psd")==0)
return 4;
else if(stricmp(ext,".pdf")==0)
return 5;
else if(stricmp(ext,".txt")==0)
{
// m_listCtrl.InsertItem(0,"txt");
return 6;
}
else
return 0;
如果上面的被注释的语句没有注释掉,则返回值正常
否则当ext=".txt"时返回0……
解决方案 »
- 今天加班
- 给大家介绍一款好的工具阿
- 关于字符串操作的一个问题``
- 关于进度条的问题
- 有句代码看不懂if(in.find(key)==Mass::npos)
- 我用Vb寫程序,MDI子窗體跟vc中普通de對話框一樣(沒有3d),而vc中用formview實現時卻是凹進去的,請問怎樣使得子窗體跟普通對話寬一樣
- 对于sdi程序,在winapp的InitInstance()函数中想获得框架mainfrm以便向框架的状态条中添加字符串,请问如何获得框架mainfrm呀?
- 怀旧--C语言连接ODBC的书或资料--十万火急
- 菜鸟问题
- 搞不懂从App Wiz出来的SDI,你按了保存 按纽以后,MFC都干了些什么?
- 请问如何在 CStatic 上显示位图,然后在显示文本呢?
- 用CListCtrl建立一个表格,怎样给表格加上边框?
#include "string.h"
int checkext(char *ext);
main()
{
char *p=".dwg";
printf("%d\n",checkext(p));
char buf[4];
printf("请输入扩展名:");
scanf("%s",buf);
printf("%d\n",checkext(buf));
getchar();
return 0;
}
int checkext(char *ext)
{
int i;
if(stricmp(ext,".doc")==0)
i=1;
else if(stricmp(ext,".xls")==0)
i=2;
else if(stricmp(ext,".dwg")==0)
i=3;
else if(stricmp(ext,".psd")==0)
i=4;
else if(stricmp(ext,".pdf")==0)
i=5;
else if(stricmp(ext,".txt")==0)
i=6;
else
i=0;
return i;
}
这是我写的测试代码,可以正确返回,但是我在程序里用的时候选择1 2 都可以正常返回,选择6时则返回0。