I have to input values whose frequency i don't know...
For example first input: 1 32 54 65 6
second input: 2 4 5
What i first thought was, scan the values, if new line '\n' then break the loop, but that didn't go so well, so instead i said i use characters, then i typecast to get the number but the problem with this also came that it scan one character by one and if its its a negative value its also a problem;
Something like this
#include <stdio.h>
int main(){
int myarray[20];
int i=0, data;
while(1){
scanf("%d", &data);
if (data == '\n') break;
myarray[i]=data;
}
return 0;
}
but then, scanf jumps all the special characters and look for only ints... is there a way to scan ints to an array and when there is a newline it stops?