lundi 19 octobre 2020

invalid initializer for rand() when assigning to array

#include <stdio.h>
#include <stdlib.h>
int main(){
    int n;
    for(int i= 0;i < 5; i++ ){
    //type arrayName[arraysize];
      int arrayName[5] = rand();
        printf("array[%d] = %d\n",i,arrayName[i]);
    }
    return 0;
}

I got an error about an invalid initializer for rand(); How do I add a random to the array and give it a range?




Aucun commentaire:

Enregistrer un commentaire