I enlarge its size?
printf("How many grades do you want it to be from now?\nAnswer: ");
scanf("%d", &newGradesNum);
grades = (int *)realloc(grades, newGradesNum * sizeof *grades);
gradesNum = changeGradesNum(grades, gradesNum, newGradesNum);
This is what I tried but it didn't work...
Please format the code you posted, by wrapping it in triple backticks. -> `
Use a vector.. Or create a new array with your new size.. And copy all the elements from the old array to the new one, then you delete/deallocate the original array, make sure that the original array's pointer points to the new array.
And I suggest you try reading about the xy problem
Обсуждают сегодня