gpt4 book ai didi

C 编译程序崩溃

转载 作者:行者123 更新时间:2023-11-30 19:53:17 25 4
gpt4 key购买 nike

我有一个程序,旨在将 10 个整数从一个数组复制到另一个数组。它正在编译,没有任何错误。其过程如下:-

/* Program to copy a string from one array to another array and print the second array */
#include<stdio.h>
#include<conio.h>
#define MAX 10
void main()
{
int s[MAX]; // Original array
int c[MAX]; // Array which contains the copied contents of s[MAX]
int i;
printf("Enter the string of 10 characters");
for(i=0;i<MAX;i++) // Storing elements in the original array
{
scanf("%d",s[i]);
}
for(i=0;i<MAX;i++)
{
printf("%d",s[i]);
}
printf("\n");
for(i=0;i<MAX;i++) /*Copying the elements from the original array into the duplicate array*/
{
c[i]=s[i];
}
for(i=0;i<MAX;i++) //Printing the duplicate array
{
printf("%d",c[i]);
}
}

它甚至没有打印原始数组。更不用说重复数组了,这是程序的后半部分。

最佳答案

scanf("%d",s[i]); 应为 scanf("%d",&s[i]);

关于C 编译程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14111050/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com