"Fossies" - the Fresh Open Source Software Archive

Member "edict/yn.c" (28 Dec 2002, 444 Bytes) of package /linux/privat/old/edict-2.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #include <stdio.h>
    2 
    3 int main(int argc, const char *argv[])
    4 {
    5     int c, i;
    6     const char *p;
    7     char prompt[256] = "";
    8     
    9     if (argc <= 2) {
   10         p = "yn";
   11         strcpy(prompt, "Yes or No");
   12 
   13     } else {
   14         /* get the options string */
   15         p = argv[1];
   16         for (i=2; i<argc; ++i) {
   17             strcat(prompt, argv[i]);
   18             strcat(prompt, " ");
   19         }
   20     }
   21 
   22     printf("%s [%s]:", prompt, p);
   23 
   24     i = 1;
   25     c = getchar();
   26     while (*p) {
   27         if (c == *p++)
   28             return i;
   29         ++i;
   30     }
   31 
   32     return 0;
   33 }