由于某种原因,每当我运行this program时,它都会在permute(permutater, length, lenth);
退出。当我注释掉这一行,函数甚至没有运行时,就不会发生这种情况。有什么帮助吗?
发布于 2010-01-29 00:42:36
我注意到的第一件事--您没有初始化索引变量hor
。
int permute(string permutater,int length,int lenth)
{
int hor,hor2,marker;
cout << length/lenth;
for (marker=0;marker !=(length/lenth);marker++)
{
hor2 = permutater[hor]; // <== hor is not initialized
permutater[hor] = permutater[hor-1];
permutater[hor] = hor2;
hor--;
cout << permutater;
}
}
发布于 2010-01-29 00:42:56
hor2 =换位寄存器;
hor
的价值是什么
发布于 2010-01-29 00:44:14
我在使用MSVC时遇到了以下编译错误
error C4716: 'permute' : must return a value
warning C4700: uninitialized local variable 'hor' used
https://stackoverflow.com/questions/2159147
复制相似问题