C 向数组中添加结构并更改其属性

C 向数组中添加结构并更改其属性,c,arrays,struct,C,Arrays,Struct,我试图让我的代码保存一个结构数组,并允许我编辑数组中结构的属性,但一切都会导致seg错误。我在做什么?我在代码中看到了许多问题: ifargv[2]=FCFS 答:我认为目标是比较事物。它必须是==而不是=。但这同样不适用于字符串 B.对于字符串,您必须像这样编写它!strcmpargv[2],FCFS 行p[计数器];这是不需要的。它没有任何作用 计数器必须初始化为0而不是1 我不确定struct进程的成员,但我假设它们都是整数。在scanf中,您必须传递成员的地址 扫描%d,&p[计数器].

我试图让我的代码保存一个结构数组,并允许我编辑数组中结构的属性,但一切都会导致seg错误。我在做什么?

我在代码中看到了许多问题:

ifargv[2]=FCFS 答:我认为目标是比较事物。它必须是==而不是=。但这同样不适用于字符串

B.对于字符串,您必须像这样编写它!strcmpargv[2],FCFS

行p[计数器];这是不需要的。它没有任何作用

计数器必须初始化为0而不是1

我不确定struct进程的成员,但我假设它们都是整数。在scanf中,您必须传递成员的地址

扫描%d,&p[计数器].pid

扫描%d,&p[计数器].burstTime

扫描%d,&p[计数器]。到达时间


如果它们是指向整数的指针,那么也会发生分段错误,因为它们在代码中的任何地方都没有初始化

scanf%d,p[counter].pid;->扫描%d,&p[计数器].pid;。下两个相同。打开编译器警告。如果!strcpargv[2]=FCFS{->>if!strcpargv[2],FCFS{p[counter];不执行任何操作。从1开始,但数组从0开始。
    int numOfProcesses = 0;
printf("How many processes would you like to enter: ");
scanf("%d",&numOfProcesses);
struct process p[numOfProcesses];
int counter = 1;
// This is the quantum printf(argv[1]);
// This is the type to run printf(argv[2]);
if(argv[2] = "FCFS"){
  while(counter < numOfProcesses){
    int temp;
    p[counter];
    printf("For process %d: \n",counter);
    printf("Enter the pid: ");
    scanf("%d", p[counter].pid);
    printf("Enter the burst time: ");
    scanf("%d",p[counter].burstTime);
    printf("Enter the arrival time: ");
    scanf("%d",p[counter].arrivalTime);

    counter++;
  }