Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 一个数组影响另一个,两个数组分别声明_C_Arrays - Fatal编程技术网

C 一个数组影响另一个,两个数组分别声明

C 一个数组影响另一个,两个数组分别声明,c,arrays,C,Arrays,我在编写一些代码时遇到了这个问题。我声明了两个数组,一个数组称为start,它被初始化为字符串hello。第二个数组被称为user,应该用for循环声明为。。但是,我的名为start的数组被修改,因此我的输出如下所示: Printed word: Hello Array Length: 5 _____o 为什么要重写我的起始数组?对不起,如果这是一个我正在自学的noob问题 #include <stdio.h> #include <string.h> int ma

我在编写一些代码时遇到了这个问题。我声明了两个数组,一个数组称为start,它被初始化为字符串hello。第二个数组被称为user,应该用for循环声明为。但是,我的名为start的数组被修改,因此我的输出如下所示:

Printed word: Hello

Array Length: 5

_____o
为什么要重写我的起始数组?对不起,如果这是一个我正在自学的noob问题

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

int main(void)
{   
    size_t length = 0;
    char start [] = {"Hello"};
    printf("\nPrinted word: %s\n", start);
    length = strlen(start);
    printf("Array Length: %zi\n", length);

    char user[] = {0};

    for(size_t x = 0; x < length; x++){   //starting here
        user[x] = '_'; 
    }

    printf("%s\n",start);
}
#包括
#包括
内部主(空)
{   
尺寸长度=0;
char start[]={“Hello”};
printf(“\n打印字:%s\n”,开始);
长度=strlen(开始);
printf(“数组长度:%zi\n”,长度);
字符用户[]={0};
对于(size_t x=0;x