小编Wil*_*iam的帖子

c - 为什么我的for循环没有执行scanf?

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char firstName1[20];
    char lastName1[20];
    char firstName2[20];
    char lastName2[20];
    char firstName3[20];
    char lastName3[20];


    int scores[18];

    scanf("%s", &firstName1[0]);
    scanf("%s", &lastName1[0]);

    printf("%s ", &firstName1[0]);
    printf("%s ", &lastName1[0]);

    //this for loop here is not being executed, could it be a formatting 
    issue? 
    //%i or %d?
    int i=0;
    for(i=0;i>6;i++)
    {
        scanf(" %d ", &scores[i]);
    }


    int j=0;
    for(j=0;j>6;j++)
    {
        printf("%i", &scores{j]);
    }

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

提供的图片显示输出结果,输入名称和打印名称有效,但是没有执行带有scanf的循环得分

代码的第一部分采用名称并将其打印回来,但是其余的代码(作为for循环)没有被执行.

c arrays for-loop scanf

2
推荐指数
1
解决办法
54
查看次数

标签 统计

arrays ×1

c ×1

for-loop ×1

scanf ×1