0

I was pretty surprised that there wasn't a question like this already -- I feel like I may be poorly describing this so apologies if this is a duplicate.

I have a program that I pull a line in from stdin with getline, and then want to read integers separated by any kind of whitespace into a linked list. I need to skip past an integer once I read it, and I'm not sure about the best way to do this.

Currently, I have sscanf reading it into a char pointer, atof'ing the char pointer and putting it into my Node value field, and have two loops to respectively skip 1) the integer digits and 2) the whitespace characters.

I feel like there should be a more elegant way to do this, specifically where sscanf reads into an integer pointer instead of a char pointer -- any ideas?

Liam Wilson
  • 179
  • 1
  • 9
  • See [scanf() skip variable](https://stackoverflow.com/questions/7607550/scanf-skip-variable). If that's not what you are asking about then post the actual code. – dxiv Oct 10 '20 at 02:19
  • Or use strtol as it was indented to be used. See [Answer: Extracting Numeric Values From a Buffer](https://stackoverflow.com/a/64217643/3422102) – David C. Rankin Oct 10 '20 at 08:35

0 Answers0