+ 2

error on c compiler when printing \t

i am writing a calendar script when ever i require to print the tab using \t it trow only a space https://code.sololearn.com/cGDJIN1HvlpU/?ref=app

7th Dec 2017, 11:06 AM
Umar Haruna Abdullahi
Umar Haruna Abdullahi - avatar
11 odpowiedzi
+ 6
This article may help. https://stackoverflow.com/questions/8657702/what-do-t-and-b-do Basically don't use tabs. use printf formatting. Tabs are not well suited for formatting
7th Dec 2017, 11:14 AM
jay
jay - avatar
+ 6
printf("%2d", 1); // two spaces printf("%4d", 2); // four spaces
7th Dec 2017, 11:40 AM
jay
jay - avatar
+ 6
here is another reference which is probably more helpful than the last https://alvinalexander.com/programming/printf-format-cheat-sheet
7th Dec 2017, 11:42 AM
jay
jay - avatar
+ 6
https://code.sololearn.com/c0Jcw3BP6lTr/?ref=app note: you should probably do the same for the days. (not use tabs that is)
7th Dec 2017, 11:44 AM
jay
jay - avatar
+ 6
you can do your second example like this. note the space between \b and \t (b is backspace) https://code.sololearn.com/ckQCwKsmYGbX/?ref=app
7th Dec 2017, 11:48 AM
jay
jay - avatar
+ 5
I do get it, this is what I mean by printf formatting http://www.teach.cs.toronto.edu/~ajr/209/notes/printf.html#modifier
7th Dec 2017, 11:27 AM
jay
jay - avatar
7th Dec 2017, 11:45 AM
Umar Haruna Abdullahi
Umar Haruna Abdullahi - avatar
0
you don't get the questions, i was trying to print tab using printf("\tSun\tMon\n"); but the complier not returning the correct output
7th Dec 2017, 11:23 AM
Umar Haruna Abdullahi
Umar Haruna Abdullahi - avatar
0
like what can you writ a small code with will print tab for me
7th Dec 2017, 11:28 AM
Umar Haruna Abdullahi
Umar Haruna Abdullahi - avatar
0
no in complir and let me see the output https://code.sololearn.com/cGDJIN1HvlpU/?ref=app
7th Dec 2017, 11:43 AM
Umar Haruna Abdullahi
Umar Haruna Abdullahi - avatar
0
thanks you
7th Dec 2017, 11:46 AM
Umar Haruna Abdullahi
Umar Haruna Abdullahi - avatar