I'm doing a complex homework assignment, so I decided to try and break it up into steps so I can figure it out easier but even the small steps are turning out to be very difficult for me.
My problem is I can't figure out how to populate this array with a unknown size. Additonally I am a very noob at this programming and am having trouble correcting these errors. Could someone please help me? Thanks.
Code://Populating Array
//Printing the Array
#include <stdio.h>
void printArray(int);
int main(void)
{
char more_to_process;
int num[], i=0;
printf("Are there any more numbers to be converted?\n");
printf("Please type Y to continue and N if you want to stop \n");
scanf("%c", &more_to_process);
while ((more_to_process != 'Y') && (more_to_process != 'N'))
{
printf("Please type Y to Continue and N if you want to stop \n");
scanf("%c", &more_to_process);
}
if (more_to_process = 'Y'){
printf("\nENTER THE NUMBER\n");
scanf("%d",num[i]);
else
for(x = 0;x <= i; x++){
printArray(num[x])
}
}
}
printArray(int num)
{
printf("%d\n",num);
}
ERRORS
Quote:
Array1.c: In function 'main':
Array1.c:12: error: array size missing in 'num'
Array1.c:26: error: expected '}' before 'else'
Array1.c:27: error: 'x' undeclared (first use in this function)
Array1.c:27: error: (Each undeclared identifier is reported only once
Array1.c:27: error: for each function it appears in.)
Array1.c:29: error: expected ';' before '}' token
Array1.c: At top level:
Array1.c:31: error: expected identifier or '(' before '}' token
Array1.c:33: warning: conflicting types for 'printArray'
Array1.c:6: warning: previous declaration of 'printArray' was here