Standard escape codes are prefixed with Escape
:
- Ctrl-Key:
^[
- Octal:
\033
- Unicode:
\u001b
- Hexadecimal:
\x1B
- Decimal:
27
So there were a few threads going around recently about a challenge to write the longest sequence of keywords in Javascript:
There are, however, a few problems:
In the realm of death by a thousand cuts, please stop using std::endl
and remove it from code.
Per cppreference.com, std::endl
"inserts a newline character into the output sequence... and flushes it". Okay, so why exactly shouldn't it be used???
There have been numerous articles written about endl
that echo the sentiment against using it. Here's some:
C++ currently offers only truncating integer division. As a consequence, the remainder operator's sign is same as the sign of the dividend. Alternative rounding modes and remainder sign behaviour are useful.
This proposal adds an <intdiv>
header containing free functions for obtaining the quotient and remainder for different rounding modes, such as rounding towards the nearest integer, towards the infinities, etc.
main(){char s[10];scanf("%[^\n]",s);printf("(%.*s) %.*s-%.*s",3,s,3,s+3,4,s+6);} |
// Compares types of both parameters. Returns true if the types are compatible, otherwise false. | |
// Parameter y may not be a variably-modified type. | |
// Designed to be a drop-in replacement for gcc's __builtin_types_compatible_p | |
#define types_compatible_p(x, y) _Generic(((typeof_unqual(x)*){}), typeof_unqual(y)*:1, default:0) | |
// Cast the bits of arg to type. Parameter type must be a type and must not be a literal or object with that type. | |
// Designed to be compatible with g++'s __builtin_bit_cast | |
#define bit_cast(type, ...) ( \ | |
union{typeof(__VA_ARGS__) in; typeof(type) out; \ | |
int enforce_type:_Generic((int(*)(int(type)))0, \ |
#include <stdio.h> | |
#define py_for(...) for(int loop_flag = 2, break_called = 0; loop_flag && !break_called; --loop_flag)if((loop_flag == 2) && !break_called)for(__VA_ARGS__, break_called = 0)if((break_called = 1), 0){}else | |
#define py_whl(...) py_for(;__VA_ARGS__;(void)0) | |
int main(){ | |
py_for(int i = 0; i < 5; ++i){ | |
printf("%d\n", i); | |
}else{ | |
puts("egg"); |