title: How do I check if SELECT statement returns no rows in C with SQLITE?
body: <p>I want to create a registration function and I want to verify if a user name is already in my database. I do not know how to verify if "SELECT" statement returns NULL. This is what i wrote so far:</p>
  
  <pre><code>strcat(msg, "Insert username:\n");
  
  if(write(client, msg, 100) &lt;= 0)
  {
  perror("Error");
  exit(1);
  }
  
  if(read(client, name, 30) &lt;= 0)
  {
  perror("Error");
  exit(1);
  }
  sqlite3_stmt *res;
  char sql[100];
  
  sprintf("SELECT * FROM users where name=\"%s\";", name);
  
  int rc = sqlite3_prepare_v2(db, sql, -1, &amp;res, NULL);
  
  if(rc != SQLITE_OK)
  {
  perror("Error");
  exit(1);
  }
  
  int step = sqlite3_step(res);
  if(step != SQLITE_DONE)
  {
  perror("Error");
  exit(1);
  }
  </code></pre>