with streams I would try using the peek() and/or putback(), method of istreams.
Code:
char ch;
int charIndex = 0;
int stringIndex = 0;
char buffer[300][300];
int intIndex = 0;
int nums[300];
fin >> ch;
while(!fin.eof() && intIndex < 300 && stringIndex < 300)
{
if(isdigit(ch))
{
fin.putback(ch);
fin >> num[intIndex++];
fin >> ch;
}
else if (ch == ' ' && charIndex < 299)
{
if(isdigit(fin.peek())
{
buffer[stringIndex++][charIndex] = '\0';
charIndex = 0;
}
else
{
buffer[stringIndex][charIndex++] = ch;
}
}
else if (charIndex < 299)
{
buffer[stringIndex][charIndex++] = ch;
}
}
But that looks rather silly (and doesn't deal with the issue of what to do if charIndex == 299 yet either). So if at all possible I would try to change the file structure to delimit the string from the int using a ~ (or some other char not otherwise allowed in the file) rather than a space because then I could use getline() easily.