I am trying to determine the size of an array by having the user input the size of the array after being prompted (because I don't know how many grades I'll have per test)...
It doesnt seem to like the line where scanf ("%c",&grades[i]);
Here is the whole function:
#include <stdio.h>
int main (void)
{
int numGrades;
char grades;
char i;
int x;
printf ("Enter The Amount Of Numbers In Your Array: ");
scanf("%i", &numGrades);/*Stores Amount Of Grades In The Array*/
for (x = 0; x < numGrades; ++x)
{
printf ("\nEnter the grade: ");
scanf ("%c",&grades[i]);
}
return 0;
}
How can I pass the array size as a parameter so that I can accept an array of any size? (I will be adding a function that will take all the grades and combine them together by letter)
char gradestochar* grades. And afterscanf, do this.grades = malloc(numGrades);gradesis supposed to be an array (or a pointer to char), not a singlechar