#include <stdio.h>
#include <string.h>
#define N 5
char username[N+3][20]={"ana","sofia","maria","isabel","joao","hugo","francisco","pedro"};
char str[20];
read_username()
{
printf("Insert your username: ");
gets(str);
}
void searchusername(int n)
{
int i;
for(i=0;i<=n;i++)
{
if(strstr(username[i], str) != NULL)
printf("username exists")
}
}
int main()
{
read_username();
searchusername(8);
}
I have the code to check if username exists, but i can´t seem to turn it around so i only get the printf when username doesn't exist, any other way without using NULL is also okay, ty.