如何解决我无法使用C调试程序,而且我不知道该怎么做,Visual Studio只是建议我添加“;”在“ = 1”,“ <9”,“ ++”之间
#include <sdio.h>
int main(void)
for (int k = 1,k <19,k++); {
printf("%d*%d=%d \n",k,k * k);
return 0;
}
我刚刚开始学习C并面对这个问题。如果可以的话,另外向我推荐入门的好指南。 :)
解决方法
问题出在这一行:
for (int k = 1,k <19,k++);
在for语句中,应使用分号(;
)分隔元素
for (int k = 1; k <19; k++)
在其末尾也没有(;
)。
此外,您应包括<stdio.h>
而不是<sdio.h>
。
您的代码包含多个语法错误和多个逻辑错误。而且原始版本的格式很差,几乎是人类无法理解的。
您想要这个:
#include <stdio.h>
int main(void)
{
for (int k = 1; k < 19; k++)
{
printf("%d*%d=%d \n",k,k * k);
}
return 0;
}
您的原始代码重新格式化并带有注释:
#include <sdio.h>
int main(void)
// { missing here
for (int k = 1,k++); { // the final ; should not be here
// ^ ^ use ; instead of,printf("%d*%d=%d \n",k * k);
return 0; // should not be in the loop but after the loop
}
// } missing here
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。