Last time I tried, MSVC++'s fgets() was really really screwy
| 180 | |
| 181 | // Last time I tried, MSVC++'s fgets() was really really screwy |
| 182 | ILbyte *iFgets(char *buffer, ILuint maxlen) |
| 183 | { |
| 184 | ILuint counter = 0; |
| 185 | ILint temp = '\0'; |
| 186 | |
| 187 | while ((temp = igetc()) && temp != '\n' && temp != IL_EOF && counter < maxlen) { |
| 188 | buffer[counter] = temp; |
| 189 | counter++; |
| 190 | } |
| 191 | buffer[counter] = '\0'; |
| 192 | |
| 193 | if (temp == IL_EOF && counter == 0) // Only return NULL if no data was "got". |
| 194 | return NULL; |
| 195 | |
| 196 | return (ILbyte*)buffer; |
| 197 | } |
| 198 | |
| 199 | |
| 200 | // A fast integer squareroot, completely accurate for x < 289. |