每次编译时,我都会不断看到此消息。我想念什么吗?我已经检查了好几次了,这似乎是正确的。错误中特别提到的那一行是在声明了main函数之后。
// Caesar Cipher Program
int main(int argc, string argv[]); //need to check that argv[1] is not a float
{
for (argc == 2 && int key = atoi(argv[1]) && key > 0) // Check that argv[0] is the file name as well? converts "key" (string) into int value
{
string text = get_string("plaintext: ");// Prompts user for plaintext
printf("ciphertext: ");// Prints ciphertext
for (int i = 0, n = strlen(text); i < n; i++)// Example of good design bc doesn't have to check the length of the string on every iteration
{
if (isalpha(text[i]) == true && isupper(text[i]) == true)
{
int j = 'text[i]' % 65;
int k = (j + key) % 26;
printf('65 + k');
}
else if (isalpha(text[i]) == true && islower(text[i]) == true)
{
int l = 'text[i]' % 97;
int m = (l + key) % 26;
printf('97 + m');
}
else
printf(text[i]);
}
return 1;
}
default
printf("Try again.");
return 0;
}
答案 0 :(得分:0)
我刚刚发现了错误如果您看您在主函数的顶部用分号结束,则不应为:
int main(int argc, string argv[])
; //need to check that argv[1] is not a float
而是:
int main(int argc, string argv[]) //need to check that argv[1] is not a float
如果看到多余的分号。希望对您有所帮助,请告诉我。