Posted November 18, 2015
![nightcraw1er.488](https://images.gog.com/e380dd5e8249f4ce94a3f215ccf0d99c50bf82e19aacc8e4bc3bd02da7c7e8c6_avm.jpg)
nightcraw1er.488
HelpThe Aged-Me!
Registered: Apr 2012
From United Kingdom
![mrkgnao](https://images.gog.com/c122e53a8f42189d8f91ab9adcfa4a6f31dbf48d3ad07a891b6b2ed0e1ea8a1f_forum_avatar.jpg)
mrkgnao
https://www.amazon.com/dp/B00HCZVCTO
Registered: Apr 2009
From United States
![Maighstir](https://images.gog.com/867f7c9b030c5535825039970bd2b997e7a2696a56af8319d548366868fa95aa_forum_avatar.jpg)
Maighstir
THIS KNIGHT MISLIKES THESE HEIGHTS
Registered: Nov 2008
From Sweden
Posted November 18, 2015
Months? I'm happy if I can remember what I meant when I wrote the code the night before.
![nightcraw1er.488](https://images.gog.com/e380dd5e8249f4ce94a3f215ccf0d99c50bf82e19aacc8e4bc3bd02da7c7e8c6_avm.jpg)
nightcraw1er.488
HelpThe Aged-Me!
Registered: Apr 2012
From United Kingdom
Posted November 18, 2015
![avatar](http://images.gog.com/e380dd5e8249f4ce94a3f215ccf0d99c50bf82e19aacc8e4bc3bd02da7c7e8c6_avm.jpg)
![avatar](http://images.gog.com/060c7ba2c77e9d11d4771dd3b9aa4cface2f18e033c7bcaa9154ea6739c4d705_avm.jpg)
Fun days. I remember writing meta-programs (programs that write other programs, which are then run) in SAS.
I even wrote a basic OMR (optical mark recognition) program in SAS (hey, it was the only language I knew back then).
![avatar](http://images.gog.com/060c7ba2c77e9d11d4771dd3b9aa4cface2f18e033c7bcaa9154ea6739c4d705_avm.jpg)
http://www.amazon.com/Obfuscated-Other-Mysteries-Don-Libes/dp/0471578053
Recommended.
![avatar](http://images.gog.com/060c7ba2c77e9d11d4771dd3b9aa4cface2f18e033c7bcaa9154ea6739c4d705_avm.jpg)
Users: An unfortunate necessity in coding. This could range from the sweaty paw swiping masses to the poorly bolted together automated system which rejects your code 3 out of 4 times.
![immi101](https://images.gog.com/efc780a273eff0c808dc7692ed2049e0f456a167af84e40426480e9bd6edceea_forum_avatar.jpg)
immi101
User
Registered: May 2010
From Germany
Posted November 18, 2015
![avatar](http://images.gog.com/060c7ba2c77e9d11d4771dd3b9aa4cface2f18e033c7bcaa9154ea6739c4d705_avm.jpg)
print($_)
$| = 1;
foreach my $f (@{$$lang_arr_ref[1]{$os}})
$time =~ tr/ :/__/;
$field =~ s/(\(.*?\))/ $1/g;
$new_size =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g;
[all are real life examples from MaGog's code]
You can structure/format any programming language (well, most) in a way that you can easily follow the control flow/program logic. But a regular expression just sits there as an undistinctive blob and I have to slowly go through it to discover what it does.
And if I come upon a function where several of these blobs jump at me, late at night, after several hours of staring at the screen, my brain starts to hurt.
Which is why I (try to) give every longish regexp a comment about what it does.
![dtgreene](https://images.gog.com/b13211519e73aa06f8273a50b02964660502da1a057e7466ad747d57469678b9_forum_avatar.jpg)
dtgreene
vaccines work she/her
Registered: Jan 2010
From United States
Posted November 18, 2015
low rated
Here is a silly little C example (note that I have not omitted any include statements):
int x[] = { 1,2,7,9,19, };
int main(void)
{
printf("%d", 3[x]);
}
Here are some oddities about this example:
1. Notice that the initializer for x has a comma at the end. That is, in fact, legal.
2. If you notice, I never declared printf anywhere, yet this still compiles. C does not require functions to be declared, though you can get into trouble depending on the types of the parameters and the return type. Note that gcc emits a warning here by default, and a C++ compiler will reject it entirely.
3. Here is the one that will probably surprise most people. Normally, you index the array with syntax x[3], which is rewritten by the compiler as *(x + 3). However, it turns out that you can write 3[x], which will be rewritten as *(3 + x). which means the same thing. So, believe it or not, 3[x] is legal C syntax.
4. Wait, where did the return statement go?
int x[] = { 1,2,7,9,19, };
int main(void)
{
printf("%d", 3[x]);
}
Here are some oddities about this example:
1. Notice that the initializer for x has a comma at the end. That is, in fact, legal.
2. If you notice, I never declared printf anywhere, yet this still compiles. C does not require functions to be declared, though you can get into trouble depending on the types of the parameters and the return type. Note that gcc emits a warning here by default, and a C++ compiler will reject it entirely.
3. Here is the one that will probably surprise most people. Normally, you index the array with syntax x[3], which is rewritten by the compiler as *(x + 3). However, it turns out that you can write 3[x], which will be rewritten as *(3 + x). which means the same thing. So, believe it or not, 3[x] is legal C syntax.
4. Wait, where did the return statement go?
![real.geizterfahr](https://images.gog.com/f473b602c0844bc49ea0495baa04fdbd97357cfc2025ae8ac0ea19d150347385_forum_avatar.jpg)
real.geizterfahr
Grumpy Old Gamer
Registered: Apr 2010
From Spain
Posted November 18, 2015
![avatar](http://images.gog.com/10a83da5623459ed1680a54fc0c03623ad7b0eae4c186a70bd87cde8a6226e12_avm.jpg)
If you're interested in responsive layouts, here's an awesome website about the power of CSS: http://www.csszengarden.com/
Every design on this site has the same HTML code! And all designs work on all kinds of devices. A great source of inspiration ;)
![immi101](https://images.gog.com/efc780a273eff0c808dc7692ed2049e0f456a167af84e40426480e9bd6edceea_forum_avatar.jpg)
immi101
User
Registered: May 2010
From Germany
Posted November 18, 2015
hate to be nitpicking, but iirc that brings you into the murky area of "undefined behaviour". That means: yes the you can compile that, but don't you try and use the return value of that function. There is no guarantee what the compiler will put there. So while that may be legal syntax according to the standard, just add your own personal law and declare it illegal :p.
![Tallima](https://images.gog.com/710f0c92869394dc1567fde6f6a337889b9fd6b4892d0c8a824276d30058d56d_forum_avatar.jpg)
Tallima
TreasureHunting!
Registered: Apr 2010
From United States
Posted November 19, 2015
![avatar](http://images.gog.com/84e4009ffa47e32f3e68cd0e0749c449c928bfafc34697bdac94f5839c9611c5_avm.jpg)
(I'm still waiting to see someone figure out how to build an e-nary computer -- that's technically the most efficient)
![avatar](http://images.gog.com/3b007c3bba753fb4b1f2e418ece1a216fb18b0b1deb9d4d988b0cbae7a54f6ab_avm.jpg)
(Note that I actually do have a mathematics background, so it is not a problem if that site is heavy on math.)
I hope you understand it better than I. :)
![dtgreene](https://images.gog.com/b13211519e73aa06f8273a50b02964660502da1a057e7466ad747d57469678b9_forum_avatar.jpg)
dtgreene
vaccines work she/her
Registered: Jan 2010
From United States
Posted November 19, 2015
low rated
![avatar](http://images.gog.com/3b007c3bba753fb4b1f2e418ece1a216fb18b0b1deb9d4d988b0cbae7a54f6ab_avm.jpg)
int x[] = { 1,2,7,9,19, };
int main(void)
{
printf("%d", 3[x]);
}
[...]
4. Wait, where did the return statement go?
![avatar](http://images.gog.com/efc780a273eff0c808dc7692ed2049e0f456a167af84e40426480e9bd6edceea_avm.jpg)
According to
http://stackoverflow.com/questions/18402853/must-the-int-main-function-return-a-value-in-all-compilers
the standard defines the return value of main() to be 0 if no return statement is reached. One of the answers cites § 3.6.1 from the standard.
(Note that this only applies to main(). Also, it apparently doesn't apply in C89, but does in later versions of the standard.)
In other words, the return value of main() in this example is in fact defined; my example does not, in fact, contain any undefined behavior. Surprised?
![mrkgnao](https://images.gog.com/c122e53a8f42189d8f91ab9adcfa4a6f31dbf48d3ad07a891b6b2ed0e1ea8a1f_forum_avatar.jpg)
mrkgnao
https://www.amazon.com/dp/B00HCZVCTO
Registered: Apr 2009
From United States
Posted November 19, 2015
![avatar](http://images.gog.com/3b007c3bba753fb4b1f2e418ece1a216fb18b0b1deb9d4d988b0cbae7a54f6ab_avm.jpg)
(Note that I actually do have a mathematics background, so it is not a problem if that site is heavy on math.)
![avatar](http://images.gog.com/84e4009ffa47e32f3e68cd0e0749c449c928bfafc34697bdac94f5839c9611c5_avm.jpg)
I hope you understand it better than I. :)
Also, did you know that the Russian developed a ternary computer in the 50's: https://en.wikipedia.org/wiki/Setun ?
![immi101](https://images.gog.com/efc780a273eff0c808dc7692ed2049e0f456a167af84e40426480e9bd6edceea_forum_avatar.jpg)
immi101
User
Registered: May 2010
From Germany
Posted November 19, 2015
![avatar](http://images.gog.com/efc780a273eff0c808dc7692ed2049e0f456a167af84e40426480e9bd6edceea_avm.jpg)
![avatar](http://images.gog.com/3b007c3bba753fb4b1f2e418ece1a216fb18b0b1deb9d4d988b0cbae7a54f6ab_avm.jpg)
According to
http://stackoverflow.com/questions/18402853/must-the-int-main-function-return-a-value-in-all-compilers
the standard defines the return value of main() to be 0 if no return statement is reached. One of the answers cites § 3.6.1 from the standard.
(Note that this only applies to main(). Also, it apparently doesn't apply in C89, but does in later versions of the standard.)
In other words, the return value of main() in this example is in fact defined; my example does not, in fact, contain any undefined behavior. Surprised?
with your code: (i skipped the compile warnings)
~ $ gcc -o test test.c
~ $ ./test > /dev/null ; echo $?
1
~ $ gcc -std=c99 -o test test.c
~ $ ./test > /dev/null ; echo $?
0
but yes, that exception about main() was actually new to me. curios that they would write stuff like that into the standard.
though personally i rather remember one rule than one rule + one exception :D. And relying on that sort of implicit behaviour always calls for trouble imo. I rather keep my return 0; statement :)
![gooberking](https://images.gog.com/10a83da5623459ed1680a54fc0c03623ad7b0eae4c186a70bd87cde8a6226e12_forum_avatar.jpg)
gooberking
To the PIT!
Registered: Mar 2011
From United States
Posted November 19, 2015
![avatar](http://images.gog.com/10a83da5623459ed1680a54fc0c03623ad7b0eae4c186a70bd87cde8a6226e12_avm.jpg)
![avatar](http://images.gog.com/aeae42f4606a4890dc001171908b248a86880610f9e8ca55bb5d9afcfda02f26_avm.jpg)
If you're interested in responsive layouts, here's an awesome website about the power of CSS: http://www.csszengarden.com/
Every design on this site has the same HTML code! And all designs work on all kinds of devices. A great source of inspiration ;)
I knew about csszengarden but I haven't looked at it in quite some time. I think there is a lot of stuff I haven't seen.
Post edited November 19, 2015 by gooberking
![rtcvb32](https://images.gog.com/77665aa6affc77960e6b537ee348222af4d3fecc684f14d10088eae491b41e33_forum_avatar.jpg)
rtcvb32
echo e.lolfiu_fefiipieue|tr valueof_pi [0-9]
Registered: Aug 2013
From United States
Posted November 19, 2015
![avatar](http://images.gog.com/efc780a273eff0c808dc7692ed2049e0f456a167af84e40426480e9bd6edceea_avm.jpg)
though personally i rather remember one rule than one rule + one exception :D. And relying on that sort of implicit behavior always calls for trouble imo. I rather keep my return 0; statement :)
This is heavily useful for bash and shell programming, where you attach actions based on if it succeeded or failed.
My experience with shell programming is fairly limited; But gluing programs together to make something more powerful than a single program is insanely fun (if a little annoying to debug or figure out)
![Maighstir](https://images.gog.com/867f7c9b030c5535825039970bd2b997e7a2696a56af8319d548366868fa95aa_forum_avatar.jpg)
Maighstir
THIS KNIGHT MISLIKES THESE HEIGHTS
Registered: Nov 2008
From Sweden
Posted November 19, 2015
Question for CMD wizards. Say I have a directory tree as follows:
If I do robocopy D:\data\a E:\backup\data\a /E /COPYALL /B, a and below is correct, but how do I keep all attributes and security info from D:\data?
D:\
D:\data\
D:\data\a\
D.\data\a\some stuff
D:\data\b\
D:\data\b\other stuff
I want to copy D:\data\a\ to E:\backup\data\a\ - except I want to keep all attributes, ACLs, etc. of the data directory and below, not just from a and below. "b" and anything else in the data folder should NOT be included. D:\data\
D:\data\a\
D.\data\a\some stuff
D:\data\b\
D:\data\b\other stuff
If I do robocopy D:\data\a E:\backup\data\a /E /COPYALL /B, a and below is correct, but how do I keep all attributes and security info from D:\data?