Smoke HHH Smoke HHH - 12 days ago 5
C Question

Printing several \t in one line

For some weird reason my little program over here doesn't show up the way I want to.The last

\t
before Quit for a weird reason doesn't do anything.

Can anyone explain me why?

#include <stdio.h>
int n,litera;
void main (void)
{ n=1;
printf("File\tEdit\tView\tCompile\tQuit\n");
printf("Selectati optiunea aleasa:");
}

Answer

There's nothing really weird about it. Since Compile is more than 4 letters long, it eats up three spaces into the next tab block. Hence the result. Use two \t\t otherwise.

Here's a Q&D solution:

#include <stdio.h>
 #define TAB "    "

 int n,litera;

 int main (void)
 {   n=1;
     printf("File"TAB"Edit"TAB"View"TAB"Compile"TAB"Quit\n");
     printf("Selectati optiunea aleasa:");
     return 0;
 }
Comments