Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ formatted input: how to 'skip' tokens?

Tags:

Suppose I have an input file in this format:

VAL1 VAL2 VAL3
VAL1 VAL2 VAL3

I'm writing a program that would be interested only in VAL1 and VAL3. In C, if i wanted to 'skip' the second value, I'd do as follows:

char VAL1[LENGTH]; char VAL3[LENGTH];
FILE * input_file;
fscanf(input_file, "%s %*s %s", VAL1, VAL3);

Meaning, I'd use the "%*s" formatter to make fscanf() read this token and skip it. How do I do this with C++'s cin? Is there a similar command? Or do I have to read to a dummy variable?

Thanks in advance.