forked from Vhex-Kernel-Core/fxlibc
added string input with scanf()
This commit is contained in:
parent
4639a1e9ce
commit
f21cc97bb5
|
@ -273,7 +273,43 @@ int __scanf(
|
|||
// read a serie of non whitespace char from the current input stream
|
||||
// and store in the corresponding arg as a char by reference
|
||||
|
||||
/* TODO: */
|
||||
char *c = (char *) va_arg( *args, char* );
|
||||
char temp;
|
||||
|
||||
if (in->readmaxlength==-1) // read the maximum number of non-whitespace characters
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
temp = __scanf_peek( in );
|
||||
if (!isspace(temp) && temp != EOF)
|
||||
{
|
||||
*c = __scanf_in( in );
|
||||
in->readsofar++;
|
||||
c++;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
*c = '\0'; // add the mandatory terminal '\0'
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int u = 0; u < in->readmaxlength; u++ )
|
||||
{
|
||||
temp = __scanf_peek( in );
|
||||
if (!isspace(temp) && temp != EOF)
|
||||
{
|
||||
*c = __scanf_in( in );
|
||||
in->readsofar++;
|
||||
c++;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
*c = '\0';
|
||||
}
|
||||
in->readmaxlength=-1;
|
||||
ret++;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue