回复 9 楼 wp231957
还有我想定义一个指针指向static const char *tblDec_Hex = "0123456789ABCDEF";这个数组的首地址,怎么定义,char **p = tblDec_Hex不对
程序代码:
#include <stdio.h>
#include <string.h>
int main(void)
{
static char *tblHex_Bin[16] =
{
"0000","0001","0010","0011",
"0100","0101","0110","0111",
"1000","1001","1010","1011",
"1100","1101","1110","1111"
};
printf("请输入待比较字符串(长度为4位 0 1 组合):\n");
char ptmp[256]={'\0'};
scanf("%s",ptmp);
int i;
for(i=0;i<16;i++)
{
if(strcmp(tblHex_Bin[i],ptmp)==0)
{
printf("找到目标 索引值是%d\n",i);
break;
}
}
return 0;
}
/*
D:\c_source\w5\Debug>w5
请输入待比较字符串(长度为4位 0 1 组合):
0011
找到目标 索引值是3
D:\c_source\w5\Debug>w5
请输入待比较字符串(长度为4位 0 1 组合):
1111
找到目标 索引值是15
D:\c_source\w5\Debug>w5
请输入待比较字符串(长度为4位 0 1 组合):
1001
找到目标 索引值是9
*/








