How do I stop accepting input for an array when a value of -1 is entered?
This is my code for accepting input. My line of thinking is that I need to input a do while loop before the for loop, but I am not sure how to write it out.
void getdataset(int[]);
int main()
{
int dataset[LENGTH];
getdataset(dataset);
return(0);
}
void getdataset(int dataset[])
{
int lcv;
printf("Enter up to 25 values or -1 to exit: ");
for(lcv = 0; lcv < LENGTH; lcv ++)
{
scanf("%d", &dataset[lcv]);
}
}