All pastes #200985 Raw Edit

Mine

public c v1 · immutable
#200985 ·published 2006-10-13 14:38 UTC
rendered paste body
int 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;}