Annoying sscanf. Won't advance the buffer. Hah.
This had to call for some more advanced parsing:
Code:
// Test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
int main()
{
long num;
char c;
char buf[1024];
char * pEnd;
char * pStart = buf;
fgets(buf, sizeof(buf), stdin);
do
{
num = strtol(pStart, &pEnd, 10);
if (pStart != pEnd)
{
// Read succeeded; do your logic.
printf("YAY!");
}
pStart = pEnd;
c = *pStart++;
}
while (c != '\n');
}