Compiler errors 不断获得;错误:应为标识符或';)但我不明白为什么
每次编译时,我都会看到这条消息。我遗漏了什么吗?我检查了几次,似乎都是正确的。错误中特别提到的那行代码是在主函数声明之后Compiler errors 不断获得;错误:应为标识符或';)但我不明白为什么,compiler-errors,Compiler Errors,每次编译时,我都会看到这条消息。我遗漏了什么吗?我检查了几次,似乎都是正确的。错误中特别提到的那行代码是在主函数声明之后 // 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) // Ch
// 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;
}
//凯撒密码程序
int main(int argc,字符串argv[]);//需要检查argv[1]是否不是浮点
{
对于(argc==2&&int key=atoi(argv[1])&&key>0)//检查argv[0]是否也是文件名?将“key”(字符串)转换为int值
{
string text=get_string(“纯文本:);//提示用户输入纯文本
printf(“密文:”;//打印密文
for(int i=0,n=strlen(text);i
我刚刚发现你的错误,如果你看的话,你用分号结束main函数的顶部不应该是:int main(int argc,string argv[])
;<需要检查argv[1]不是浮点值,而是:
int main(int argc,string argv[])//需要检查argv[1]如果你看到你有一个额外的分号,它不是一个浮点数。希望这有助于告诉我它是否是浮点数。请编写语言int:intmain(intargc,stringargv[]);
为什么是;
?