Manipulation of character arrays
I have been having trouble with using arrays of indefinite size.
I havent had a problem I think creating an array of unknown size but I have had problems ending the program. I have noticed that others have had similiar problems but I am still unsure as to how I should go about fixing the problem.
If I were to calculate the sum of an array of size known I would do this and this works:
printf("the sum of these numbers is %i\n"sum);
this is fine for 10 numbers in the array, it will find the sum of ten numbers and terminate.
However what I want to know is what if you wanted to find 20 30 or even 40 numbers and terminate when you type in a string.
so if you were to type in 1 2 3 4 5 6 and then end it would find the sum of the 6 numbers you put in.
What I need is something that terminates the loop when a string of characters or a character is typed in. I have tried lots of things but it just hangs telling me that it is ignoring the code that I have put in. Can anybody help me.
I need to change the above code to handle this and I think it involves putting in a loop either while or for but I dont know how to implement it