Click here to Skip to main content
15,868,049 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
PraiseRe: What are some stupid-useful coding tricks you rely on? Pin
Gary Wheeler9-Jan-23 2:38
Gary Wheeler9-Jan-23 2:38 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
honey the codewitch9-Jan-23 5:18
mvahoney the codewitch9-Jan-23 5:18 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
Gary Wheeler9-Jan-23 5:23
Gary Wheeler9-Jan-23 5:23 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
honey the codewitch9-Jan-23 5:54
mvahoney the codewitch9-Jan-23 5:54 
AnswerRe: What are some stupid-useful coding tricks you rely on? Pin
Mircea Neacsu8-Jan-23 14:08
Mircea Neacsu8-Jan-23 14:08 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
honey the codewitch8-Jan-23 14:53
mvahoney the codewitch8-Jan-23 14:53 
GeneralRe: What are some stupid-useful coding tricks you rely on? Pin
CPallini8-Jan-23 20:28
mveCPallini8-Jan-23 20:28 
AnswerRe: What are some stupid-useful coding tricks you rely on? Pin
Dan Sutton9-Jan-23 6:30
Dan Sutton9-Jan-23 6:30 
In C:

a^=b^=a^=b;


...will swap the values of a and b by XORing them a couple of times, assuming a and b are the same size. Works for large data structures just as well as for ints: quite fast, too. Back in the days before proper video cards, this was good for swapping in entire screen contents, or faking sprites or whatever...

Note that this doesn't work in C#: you have to go...:

a^=b;
b^=a;
a^=b;


...because unlike C, C# uses the original values of the variables throughout the evaluation of the expression, so what happens if you try to run the original statement is that one variable receives the swap, but the other one is garbage. And really, it only works for ints. But it does let you swap the variables without using a third one.
AnswerRe: What are some stupid-useful coding tricks you rely on? Pin
HappyDotNet10-Jan-23 5:01
professionalHappyDotNet10-Jan-23 5:01 
AnswerRe: What are some stupid-useful coding tricks you rely on? Pin
englebart21-Jan-23 9:29
professionalenglebart21-Jan-23 9:29 
AnswerRe: What are some stupid-useful coding tricks you rely on? Pin
FormerBIOSGuy26-Jan-23 6:13
FormerBIOSGuy26-Jan-23 6:13 
GeneralStrange RDP problem Pin
dandy728-Jan-23 4:33
dandy728-Jan-23 4:33 
GeneralRecursively Searching for "text" in files in windows 11 Pin
jmaida7-Jan-23 18:10
jmaida7-Jan-23 18:10 
GeneralRe: Recursively Searching for "text" in files in windows 11 Pin
David O'Neil7-Jan-23 20:27
professionalDavid O'Neil7-Jan-23 20:27 
GeneralRe: Recursively Searching for "text" in files in windows 11 Pin
jmaida8-Jan-23 13:16
jmaida8-Jan-23 13:16 
GeneralRe: Recursively Searching for "text" in files in windows 11 Pin
David O'Neil8-Jan-23 13:26
professionalDavid O'Neil8-Jan-23 13:26 
GeneralRe: Recursively Searching for "text" in files in windows 11 Pin
jmaida8-Jan-23 15:38
jmaida8-Jan-23 15:38 
GeneralRe: Recursively Searching for "text" in files in windows 11 Pin
Richard MacCutchan7-Jan-23 21:11
mveRichard MacCutchan7-Jan-23 21:11 
GeneralRe: Recursively Searching for "text" in files in windows 11 Pin
jmaida8-Jan-23 13:27
jmaida8-Jan-23 13:27 
GeneralRe: Recursively Searching for "text" in files in windows 11 Pin
jschell10-Jan-23 7:37
jschell10-Jan-23 7:37 
GeneralRe: Recursively Searching for "text" in files in windows 11 Pin
yacCarsten7-Jan-23 21:23
yacCarsten7-Jan-23 21:23 
GeneralRe: Recursively Searching for "text" in files in windows 11 Pin
Jacquers7-Jan-23 23:12
Jacquers7-Jan-23 23:12 
GeneralRe: Recursively Searching for "text" in files in windows 11 Pin
BillWoodruff8-Jan-23 2:10
professionalBillWoodruff8-Jan-23 2:10 
GeneralRe: Recursively Searching for "text" in files in windows 11 Pin
jmaida8-Jan-23 13:29
jmaida8-Jan-23 13:29 
GeneralRe: Recursively Searching for "text" in files in windows 11 Pin
PIEBALDconsult8-Jan-23 3:28
mvePIEBALDconsult8-Jan-23 3:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.