When you are printing a tab character to the standard output using printf in C, it outputs some space which is apparently 4 characters in length.
printf("\t");
Is there a way by which I can control the tab width in the above case?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A tab is a tab. How many spaces it consumes is a display issue, and depends on the settings of your shell.
If you want to control the width of your data, then you could use the width sub-specifiers in the
printfformat string. For example,It’s not a complete solution (if the value is longer than five characters, it will not be truncated), but it might be OK for your needs.
If you want complete control, you’ll probably have to implement it yourself.