title: How to pass escape sequence like tab and newline char as command line argument in C programming getopt_long?
body: <p>I almost reached end of my code, after a lot of search I didn't find solution no where, I want to supply escape sequence like '\t', '\n' to my program like how <code>awk</code> and <code>perl</code> program takes, and finally I want to use them as printf or sprintf format string</p>
  
  <p>This is what I tried so far, <strong>please note I need to have variable delim and rs should be  pointer.</strong></p>
  
  <pre><code> #include &lt;stdio.h&gt;
   #include &lt;stdlib.h&gt;
   #include &lt;getopt.h&gt;
  
  
   int main (int argc, char **argv)
   {
     int c;
  
     char *delim = ",", *rs = "\n\r";
  
     while (1)
       {
         static struct option long_options[] =
           {
  
             {"delim",  required_argument, 0, 'd'},
             {"row_sep",  required_argument, 0, 'r'},
             {0, 0, 0, 0}
           };
  
         int option_index = 0;
  
         c = getopt_long (argc, argv, "df",
                          long_options, &amp;option_index);
  
  
         if (c == -1)
           break;
  
         switch (c)
           {
           case 0:
  
             if (long_options[option_index].flag != 0)
               break;
             printf ("option %s", long_options[option_index].name);
             if (optarg)
               printf (" with arg %s", optarg);
             printf ("\n");
             break;
  
           case 'd':
             delim = optarg;
             break;
  
           case 'r':
             rs = optarg;
             break;
  
           case '?':
             break;
  
           default:
             abort ();
           }
       }
  
  
     /* Print any remaining command line arguments (not options). */
     if (optind &lt; argc)
       {
         printf ("non-option ARGV-elements: ");
         while (optind &lt; argc)
           printf ("%s ", argv[optind++]);
         putchar ('\n');
       }
  
  
  
   /* Test input argument */
  
  
   printf("This is test%ssome text%s",delim,rs);
  
  
  
     exit (0);
   }
  </code></pre>
  
  <p>When I compile and execute I get output like this</p>
  
  <pre><code> $ gcc argument.c
  
   $ ./a.out --delim="\t"
   This is test\tsome text
  
   $ ./a.out --delim="\t" --row_sep="\n"
   This is test\tsome text\n
  </code></pre>
  
  <p>I expect it to print tab and newline instead of '\t' and '\n' as original</p>
  
  <p>Kindly someone help me.</p>