fork download
  1. #include <string.h>
  2. #include <stdio.h>
  3.  
  4. void ler_string(char* destino, size_t tamanho_leitura){
  5. fgets(destino, tamanho_leitura, stdin);
  6. size_t ultima_pos = strlen(destino) - 1;
  7. if (destino[ultima_pos] == '\n'){
  8. destino[ultima_pos] = '\0';
  9. }
  10. }
  11.  
  12. int main(){
  13.  
  14. char username[25];
  15. char passwd[45];
  16.  
  17. printf("Input your name ->");
  18. ler_string(username, 25);
  19.  
  20. printf("Input your password->");
  21. ler_string(passwd, 45);
  22.  
  23. char query[128];
  24. sprintf(query,"select username, password from accounts where username='%s' and password='%s'\n", username, passwd);
  25. printf("%s", query);
  26.  
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0s 4384KB
stdin
linus
123
stdout
Input your name ->Input your password->select username, password from accounts where username='linus' and password='123'