Link to home
Start Free TrialLog in
Avatar of cflores89
cflores89

asked on

How do I split a cin << string into integers?

Hey All,

I'm looking for a way to input 10 ints from a string.

I've tried the code below it doesn't work, since it is expecting th NULL. And other examples on here use char with built in text so that you can use NULL in the while loop. I then tried with the EOL but I run into char to int comparisons.

Ideally, I'd liek something simple like Java

 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       
        for (String s_in: args){
            System.out.println(s_in);
           
        }
       


Thank you

{
	char inputString[200];
	const char EOL = '\n';
	char delims[] = " ";
	char *result = NULL;
	result = strtok(inputString, delims);
	while (result != EOL)
	{
		// conver to int and add to Q here
	}
 
 
	/*
	fillQ[x].enqueue(768);
	fillQ[1].enqueue(685);
	fillQ[2].enqueue(767);
	fillQ[3].enqueue(663);
	fillQ[4].enqueue(250);
	fillQ[5].enqueue(755);
	fillQ[6].enqueue(386);
	fillQ[7].enqueue(893);
	fillQ[8].enqueue(544);
	fillQ[9].enqueue(740);
*/
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of evilrix
evilrix
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cflores89
cflores89

ASKER

Thank you very much! :)

stringstream was what i was looking for