Open goldfishgggg opened 1 year ago
implicit declaration of function 'getline'; did you mean 'getenv'? [-Wimplicit-function-declaration]gcc
"I encountered this issue on Windows 10 and found that this function may not work on Windows. So, I tried running the same code under WSL and it worked successfully.
You can try to implement this function by yourself on windows. `ssize_t getline(char *linep, size_t n, FILE fp) { int ch; size_t i = 0; if (!linep || !n || !fp) { return -1; } if (linep == NULL) { if (NULL == (linep = malloc(n = 128))) { *n = 0; return -1; } }
while ((ch = fgetc(fp)) != EOF)
{
if (ch == '\n')
break;
if (i + 1 >= *n)
{
char *temp = realloc(*linep, *n + 128);
if (!temp)
{
return -1;
}
*n += 128;
*linep = temp;
}
(*linep)[i++] = ch;
}
(*linep)[i] = '\0';
return !i && ch == EOF ? -1 : i;
}`
implicit declaration of function 'getline'; did you mean 'getenv'? [-Wimplicit-function-declaration]gcc