I want to learn to use the functions and data structures that come with utmp.h. In the code below I wanted to iterate through the utmp structs and print their data fiels.
#include <stdio.h>
#include <utmp.h>
int main()
{
struct utmp *data;
data = getutent();
int i = 0 ;
while(data != NULL)
{
++i;
printf("%s\n" , data->ut_id);
data = getutent();
}
printf("%d" , i);
return 0 ;
}
Even though ut_id is of type char[4], when I run the code I get this warning:
warning: ‘__builtin_puts’ argument 1 declared attribute ‘nonstring’ [-Wstringop-overflow=]
How can I fix it?