input of the form: 2 4 1 3 2 1 2 0

how can we take an input of the form;
2 4 1 3 2 1 2 0
on the console from the user and then use the integers for further processing;
there is a space after every integer;

i try doing it the following way;
but strtol only converts before the space;

1
2
3
4
5
6
7
8
9
10
cout<<"Enter the Equation : \n";
	cout<<"Equation 1: \n ";
	
	char str[11];	
	fflush(stdin);
	cin.getline(str,11,'\n');
	
	int temp;
	temp = strtol(str,NULL,10);
	cout<<temp;
Last edited on
Last edited on
thanks @tath
Topic archived. No new replies allowed.