C++ using the tab "\t" error

C++ using the tab "\t" error

de Ana Ferraz -
Número de respuestas: 2

I tried using the tab special character "\t" to organize the output in a question and it prints \t like the image below.


Is there a way to use a tab in CodeRunner? 

En respuesta a Ana Ferraz

Re: C++ using the tab "\t" error

de Richard Lobb -

Short answer: no. The behaviour of \t isn't well undefined in general. Some contexts assume tab stops every 4 characters, some every 8, some allow user-configuration of tabs.

If you want columnar output you either need to manage it yourself (e.g. by post-processing the output to do tab expansion or by using a combinator-template-grader, which gives you ultimate control over the output albeit with a considerable step up in complexity) or use HTML-formatted columns (see documentation here).

Usually, though, the best approach is to make use of field-width specifiers in whatever language you're using for printing the output.

Richard

En respuesta a Richard Lobb

Re: C++ using the tab "\t" error

de Ana Ferraz -

Thank you Richard for the quick reply. 

Since it's harder than what I thought, I won't look for other solutions... I will change the question then