英文:
Why isn't my Vscode running my simple program and how can I fix it?
问题
以下是您要翻译的部分:
"My code should be way simple yet whenever I run it I get this:"
我的代码应该非常简单,但每次运行它时,我都会得到这个错误:
"c:\Users<MyLaptop'sname>.vscode\extensions\ms-vscode.cpptools-1.15.4-win32-x64\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-tcoej3zt.jpf' '--stdout=Microsoft-MIEngine-Out-mgt55pxk.t32' '--stderr=Microsoft-MIEngine-Error-irnbbu1z.cvb' '--pid=Microsoft-MIEngine-Pid-4hc4rdjl.5xd' '--dbgExe=C:\msys64\mingw64\bin\gdb.exe' '--interpreter=mi'
程序无法请求输入。
"I got an assignment in 5 days and not even my IDE is working. I wouldn't mind other IDE's suggestions in case this won't work cuz I been trying for a while"
我有5天的作业,但连我的集成开发环境都无法工作。如果这不起作用,我也不介意其他集成开发环境的建议,因为我已经尝试了一段时间。
#include <stdio.h>
int main()
{
int i, j, n, mat[n][n];
printf("Enter the size of the matrix: ");
scanf("%d", &n);
printf("Enter the elements of the matrix: ");
for (i = 0; i < 2; i++)
{
for (j = 0; j < 2; j++)
{
scanf("%d", &mat[i][j]);
}
}
for (i= 0 ; i < n ;i++){
for (j=0; j< n;j++)
{
printf("%d", mat[i][j]);
}
printf(" ");
}
return 0;
}
我只提供了您要翻译的部分,没有其他内容。
英文:
My code should be way simple yet whenever I run it I get this :
c:\Users\<MyLaptop'sname>\.vscode\extensions\ms-vscode.cpptools-1.15.4-win32-x64\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-tcoej3zt.jpf' '--stdout=Microsoft-MIEngine-Out-mgt55pxk.t32' '--stderr=Microsoft-MIEngine-Error-irnbbu1z.cvb' '--pid=Microsoft-MIEngine-Pid-4hc4rdjl.5xd' '--dbgExe=C:\msys64\mingw64\bin\gdb.exe' '--interpreter=mi'
and the program doesn't even ask for an input
I got an assignment in 5 days and not even my IDE is working. I wouldn't mind other IDE's suggestions in case this won't work cuz I been trying for a while
#include <stdio.h>
int main()
{
int i, j, n, mat[n][n];
printf("Enter the size of the matrix: ");
scanf("%d", &n);
printf("Enter the elements of the matrix: ");
for (i = 0; i < 2; i++)
{
for (j = 0; j < 2; j++)
{
scanf("%d", &mat[i][j]);
}
}
for (i= 0 ; i < n ;i++){
for (j=0; j< n;j++)
{
printf("%d", mat[i][j]);
}
printf(" ");
}
return 0;
}
I was trying to just run this code to test my Vscode after it went mad and stopped compiling or running code.
答案1
得分: 1
Your program won't compile because the array mat has the size n*n, and n is not initialised at this point. If you declare the array after you ask the user for n, it should compile.
英文:
your program won't compile because the array mat has the size n*n, and n is not initialised at this point. if you declare the array after you ask the user for n, it should compile.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论