请各位大佬答疑解惑,关于C代码的问题
运行环境:VSCode(自己配置了gcc/gdb)
版本:gcc (MinGW.org GCC-6.3.0-1) 6.3.0
因为没有下Visual Studio,使用了在线编译器Wandbox,运行结果正常,如预料,但是使用vscode运行,输出结果一直出错,请问大佬们,这是什么情况
代码段如下
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(){
srand((size_t) time(NULL));
int arr[6]={0};
int value=0,flag=0;
int i,j;
for (int i = 0; i < 6; i++)
{
value = rand()%32+1;
for (j = 0; j < flag; j++)
{
if(value==arr[j]){
i--;
printf("%d ",arr[j]);
break;
}
}
if(j==flag)
{
arr[flag] = value;
printf("%d ",arr[flag]);
flag++;
}
}
for (int i = 0; i < 6; i++)
{
printf("%d ",arr[i]);
}
return 0;
}
launch.json文件如下
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/rand.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}