I wrote a func that gets a line from user.
Running it on windoes doesn't cause any warning.
But on unix i get the warning :
function UserIO_ReadLineFromUser() returns address of local variable -wreturn-local-addr
char* UserIO_ReadLineFromUser()
{
int i = 0, lineLen = 0;
char lineFromUser[MAX_INPUT_LINE_LENGTH];
fgets(lineFromUser, MAX_INPUT_LINE_LENGTH, stdin);
lineLen = strlen(lineFromUser);
lineFromUser[lineLen-1] = '\0';
while ('\0' != lineFromUser[i])
{
lineFromUser[i] = tolower(lineFromUser[i]);
i++;
}
return lineFromUser;
}
This is how i call it on main():
int main()
{
List* pHead = NULL;
char line[MAX_INPUT_LINE_LENGTH];
while (true)
{
strcpy(line, UserIO_ReadLineFromUser());
UserIO_ExecuteLineFromUser(line, &pHead);
}
return 0;
}
The program works but i want to get rid of this warning