【发布时间】:2011-11-05 19:17:05
【问题描述】:
所以我得到了这个: char table1[10^length][length]; char table2[10^length][length];
编译器不允许我添加这个: 表1=表2;
我的代码应该采用带有通配符的字符串(仅?)
并在输出中给出所有可能的字符串(这是一个更大项目的一部分,但可以说在终端打印它们 - 如果我这样做,我可以处理其余的)
这里是完整的代码:
int ** wildReplacement(char *wildAM,int length)
{
length=7;
char * temp;
strcpy(wildAM,"123?23");
//getchar();
int i=0;
int j=0;
int k=0;
int l=0;
int limit=0;
int wildCharsNum;
char *nlptr= NULL;
char table1[10^length][length];
char table2[10^length][length];
wildCharsNum=charOccurenciesInStr(wildAM,'?');
strcpy(temp,wildAM);
strcpy(table1[0],wildAM);
printf("\n!!WildChars In wildAM:%d",wildCharsNum);
while(k<wildCharsNum)
{
l=0;
while(l<=limit)
{
strcpy(temp,table1[l]);
i=0;
nlptr = strchr(temp, '?');//ka8e fora vriskei to epomeno ?
if (nlptr)
{
for(j=1;j<10;j++)
{
*nlptr = myItoc(j);//antikatastasi tou ? me digits sto temp
strcpy(table2[i],temp);
i++;
}
}
l++;
}
table1=table2;
limit=i;
k++;
}
printf("\nWild Numbers out:");
for(i=0;i<limit;i++)
{
printf("\n%s",table1[i]);
}
}
我应该 malloc 喜欢吗:
char ** table1
char ** table2
table1=malloc(sizeof(char)*10^length*lenght)
table2=malloc(sizeof(char)*10^length*lenght)
程序如何知道每条记录何时结束
那么这意味着什么: 表 1[1] ?可能没什么...
提前致谢
【问题讨论】:
-
^不表示取幂,表示按位异或。 -
为什么
length作为参数传入然后立即设置为7? -
谢谢你 K-ballo,你说得对,我把它改成了 pow(),一切正常