【发布时间】:2015-10-22 02:01:25
【问题描述】:
我对 C 没有任何经验(尽管我经常使用 C#),但我希望编译一些 C 代码:
http://practicalcryptography.com/cryptanalysis/stochastic-searching/cryptanalysis-bifid-cipher/
当我在 VS2015 中使用开发者命令提示符用 cl.exe 编译它时,我遇到了一个错误:
c:\simple>cl bifidcrack.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
bifidcrack.c
bifidcrack.c(113): error C2113: '-': pointer can only be subtracted from another
pointer
bifidcrack.c(114): error C2113: '-': pointer can only be subtracted from another
pointer
c:\simple>
为什么编译失败?其他人(在页面 cmets 中)据说编译它没有任何问题。
C:\简单包含:
C:\simple>dir
Volume in drive C is OS
Volume Serial Number is AA86-3F24
Directory of C:\simple
22/10/2015 02:50 <DIR> .
22/10/2015 02:50 <DIR> ..
12/10/2015 12:06 4,491 bifidcrack.c
12/10/2015 12:06 7,301,392 qgr.h
12/10/2015 12:06 574 scoreText.c
12/10/2015 12:06 44 scoreText.h
4 File(s) 7,306,501 bytes
2 Dir(s) 14,560,649,216 bytes free
C:\simple>
根据要求,以下是有问题的行:
char *bifidDecipher(char *key, int period, char *text, char *result, int len){
int i, j;
char a,b; /* the digram we are looking at */
int a_ind,b_ind;
int a_row,b_row;
int a_col,b_col;
for (i = 0; i < len; i += period){
if (i + period > len){
period = len - i;
}
for (j = 0; j < period; j ++){
a = text[i+(j/2)];
b = text[i+((period+j)/2)];
/*if (index(key,a) == NULL || index(key,b) == NULL) break;*/
113 a_ind = (int)(index(key,a) - key);
114 b_ind = (int)(index(key,b) - key);
a_row = a_ind / 5;
b_row = b_ind / 5;
a_col = a_ind % 5;
b_col = b_ind % 5;
if (j % 2 == 0){
result[i+j] = key[5*a_row + b_col];
} else {
result[i+j] = key[5*a_col + b_row];
}
}
}
result[i] = '\0';
return result;
}
【问题讨论】:
-
引用的代码行会很有用...
-
添加了 bifidcrack.c 的 sn-p 并列出了第 113 行和第 114 行。希望对您有所帮助!
-
需要知道“索引”是什么。如果它没有返回
char *,那么是的,这是一个编译错误。 -
感谢您的帮助。我将如何去寻找它是什么?不幸的是,我没有任何 C 经验。我没有注意到我发布的链接现在已关闭,但如果有帮助,它仍然可以通过 TWBM 访问:web.archive.org/web/20151018181750/http://…
标签: c compilation compiler-errors