【发布时间】:2020-08-13 13:55:49
【问题描述】:
我有这段代码应该检查“密钥”,即 argv(1),但它不工作。 “分段错误”
这里是:
string plain; //this is in advance for my for loop
//was unable to find a way to actually get the thing to handle a non-numeric key :(
int main(int argc, string argv[])
{
if (argc == 2 && isdigit(argv[1]))
{
plain = get_string("plaintext:");
printf("ciphertext:");
}
else
{
printf("Usage : ./caesar key\n");
return 1;
}
感谢您的帮助,如果您需要更多详细信息,请询问!
【问题讨论】:
-
string plain;//这是我的for循环的提前这是我的get字符串
-
argv[1]不返回整个字符串吗?该方法正在寻找代表单个字符的int... -
感谢 maarten 解决了问题