Mine
public c v1 · immutableint clearstdin(void){ while (getchar() != 0x0a) { } return 0;}int get_string(int buffersize, char *output_ptr){ int success = 0; char *p; while (success != 1) { fgets(output_ptr, buffersize, stdin); if ((strchr(output_ptr, '\n')) == NULL) { clearstdin(); printf("Invalid data. Please try again.\n"); } if ((p = strchr(output_ptr, '\n')) != NULL) { *p = '\0'; success = 1; } } return 0;}