Is it “bad practice” to use tab characters in string literals?

后端 未结 2 701
执笔经年
执笔经年 2021-01-19 06:22

As a follow-up on Is it mandatory to escape tabulator characters in C and C++? (do note I\'m not the author of said question).

I\'ve learned such code is considered

2条回答
  •  北海茫月
    2021-01-19 07:10

    I've never really thought about it, but I can't imagine finding literal tabspace characters a good idea because you cannot immediately distinguish them from standard whitespace. If you need a tabspace in your string literal for some specific reason, it's more clear and explicit to write \t so that everybody knows precisely what you intended to do.

    By the way, the notion that there must be a good use case just because the standard allows it … is somewhat broken. For example, the standard allows us to declare raw pointers, and to write new.

提交回复
热议问题