URLs in C (2011)
susam.in
susam.in
And C/C++ also has the "-->" operator which, of course, is the "goes to zero" operator: https://stackoverflow.com/questions/1642028/what-is-the-oper...
And the famous joke thread from Stackoverflow with examples of file format abuse: https://stackoverflow.com/questions/5508110/why-is-this-prog...
<html> hi </html> a
This code when run as a bash script reads from a file with name "html" and writes to file "hi".
It also reads from file "html" (in the root directory) and writes to a file called "a".
The "a" in the end is just to avoid bash errors about unexpected newline.When I played with this a few years ago I actually discovered a bug in bash. If I had a bash alias with the same name as one of the filenames, bash would do alias expansion on the filename. This bug was triggered by executing a line with two redirection operators before any command.
So if you follow these steps:
$ alias a='abc xyz'
$ </ >a
you would get the error (in addition to a file created with name "abc"): bash: xyz: command not found
This happened because bash expanded the second line to: $ </ >abc xyz
and therefore treated "xyz" as a command (and "abc" and the root directory as filenames).
This bug doesn't work anymore in new versions of bash because it has been fixed. int main() {
https://acceptable/
http://okay/
https://duplicate.error/
} int main() {
https://error/
int x = 3;
}gcc for example gives the error "error: a label can only be part of a statement and a declaration is not a statement" for the code in OP's comment.
g++ happily compiles it.
See the first answer here: [1]
[0] https://en.wikipedia.org/wiki/Statement_(computer_science)
[1] https://stackoverflow.com/questions/49861965/declarations-de...
int main() {
gopher://myhost:151/hello.txt
ftp://ftp.acc.umu.se/pub/netbsd
ldap://yesherewego
dav://getmyfiles
}Brains are funny sometimes, and it is amazing how much we rely on context to remember and parse things.
int x = 1 //*
//*/2
;
Without "//" comments this is whitespace equivalent to int x = 1 / 2 ;
With "//" comments this is whitespace equivalent to int x = 1 ;
[edit]Full working demo: https://gist.github.com/jasom/41ab3712d83d7edbdc03bb8e43a7af...
Where to goto? A label, of course.
I wrote this:
#include <stdio.h>
void f() {
printf("f");
}
int main() {
goto f;
return 0;
}
It creates error: foo.c:8:10: error: use of undeclared label 'f'
goto f;
^
1 error generated.
How can we goto a function name?fun note: C-- has something like that! iirc it's like calling a function, but reusing the current stackframe:
jump f(expr1,. . .,exprn);
> "the `jump` statement performs a control jump but carrying parameters. It has as target [...] a procedure address and can optionally transfer arguments to that procedure."https://www.microsoft.com/en-us/research/wp-content/uploads/...
The concept is not so unique as you might think tho; the more commonly used term is "tail call".
re: C--, i think it's mostly used as a compiler IR. (notably in Haskell's GHC)
Nothing special
// nothing to see here