Skip to content

Instantly share code, notes, and snippets.

@adrianparvino
Created December 14, 2018 02:36
Show Gist options
  • Save adrianparvino/4fa761dfbc15a7fea2d9f4d03a9d4d70 to your computer and use it in GitHub Desktop.
Save adrianparvino/4fa761dfbc15a7fea2d9f4d03a9d4d70 to your computer and use it in GitHub Desktop.
#include"common.h"
#include<stdio.h>
#include<stddef.h>
void prompt_( char *prompt, char *dest, size_t count )
{
fprintf(stderr, "%s ", prompt);
char ch;
while(count-- > 0 && (ch = getchar()) != '\n')
{
*(dest++) = ch;
};
ungetc(ch, stdin);
while((ch = getchar()) != '\n');
}
void prompt( char *original,
char *query,
char *replacement )
{
prompt_("What is the original string?", original, 80);
prompt_("What is the query string?", query, 10);
prompt_("What is the replacement string?", replacement, 10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment