Recursive Quotation Mark Solution
In an interview I was asked Print a quotation mark using the printf() function I was overwhelmed. Even in their office there was a computer and they told me to try it. I tried like this: void main() { printf("Printing quotation mark \" "); } but as I suspected it doesn't compile. When the compiler gets the first " it thinks it is the end of string, which is not. So how can I achieve this? #include <stdio.h> int quot(int c) { if (c == '"') { return c; } else return quot(c+1); } int main(void) { printf("Printing quotation mark %c \n", quot(0)); }
A programmer is asked to print a quotation mark using the printf() function. Instead of escaping the character, they write a recursive C function that searches through character codes until it finds a quotation mark, humorously overengineering a trivial task and embodying cringe coding. EN: A programmer is asked to print a quotation mark using the printf() function. Instead of escaping the character, they write a recursive C function that searches through character codes until it finds a quotation mark, humorously overengineering a trivial task and embodying cringe coding.
computer screen / экран компьютераcode editor / редактор кодаC source code / исходный код на Cquotation mark / кавычкаkeyboard / клавиатураtext window / текстовое окноprintf function / функция printfcompiler error / ошибка компилятораrecursive function / рекурсивная функцияmonospace text / моноширинный текст
- @dev_meme / 1476 2020-05-02
- Type
- image
- Size
- 670×535 · 43.4 KiB
- Mood
- cringe, absurd
- Language
- en
- Added