Sunday, 4 December 2011

C and C++ Programming Tips


TipAuthorRating (votes)
gets is dangerouscarl johnson7.6
do not use printf without %s to print a stringpavan kumar7.5
Temporariless SwapGuille7.4
Comparisons in C\C++Nikitas Angelinas7.3
Rounding to an IntegerGorn7.3
logical error on divisionM.Kumaran7.3
assert() yourself!Kevin Lam7.2
Always write if statements with bracesWebmaster7.1
Don't use strlen in a loop condition.anonytmouse7.0
When optimizing code, focus on algorithms firstAlex Allain7.0
Passing array elements to functionsUmer khan7.0
difference between int* p and int *p declarationomprakash mishra6.9
Multiply rather than DivideReese Moore6.9
Solve Any Compiler Error EasilyWajahat Karim6.9
Better coding style for comparisonnids6.9
Standard Loop ProgressionDazzle6.9
The power of scanf()Joanna6.8
Common Optimization TipsTravis Fischer6.8
Keep a cool head when programmingSentralia6.8
High performance loopingRachana6.8
Keep fit to program betterLuna Man6.8
Pointer Tips :-)Jatin Gandhi6.8
Converting numbers to StringsWebmaster6.7
C++ new does not return 0 on failure!Are R. Svendsen6.7
Initialise all variables before useMounish6.7
Be organisedProphet-Ex6.7
Never do unary minus on sizeofVaibhav6.7
Pointer Memory allocationKrishnamoorthi6.7
Fast multiplicationJean-François Geyelin6.7
Use ++ and --Subyraj P.S6.7
Effective Modularity in ProgrammingSharma PCS6.6
Flowchartsayyapparaju6.6
The many meanings of NULLRajat Kochhar6.6
Safely using strncpyoliv296.5
Avoid void main()Webmaster6.5
initalization of objectsmohit dhawan6.5
Dont't use scanf() when reading sentencesRomnico6.5
clean up after cin (C++)Major_Small6.5
Write it out on paperrakesh kumar6.5
loop conditionKrishna6.4
LogicHardi Pertel6.4
Be careful when storing pointers inside unionssingam kiran reddy6.4
Code Optimization TipsBasker Swaminathan6.4
Be careful about array size when u are using strcpBhushan Verma6.4
Clever ways to avoid using if statementsA. Karthick Pandia Samy6.4
think before you codeTimofei Gerasimov6.4
Programming TipsJatin Gandhi6.3
Pointer arithmetic hackVivek Ahlawat6.3
Unexpected struct behavior in Borlands Turbo C++ 3Raza Sayed6.3
Effective use of ==Er.Nathan6.3
Make libraries for yourselfValseedian6.2
use of ! operatormrinal jha6.2
Initialise all variablesJia.Lu6.2
getchar() returns an intRob6.2
compiler tipJulian Sutherland6.2
Fix all compiler warningsrickey6.1
backups using CVS save you lot of spaceLeif6.1
Free The Memory That You UseUdhaya Kumar.D6.1
Use makefilecjediknight6.1
Use Good Variable And Function Namesprog-bman6.1
Error handling for newUpesh Jindal6.1
Do NOT always check for NULL! (C++)Kevin Lam6.1
gets() is bad.Sean6.1
Fastest raise to power.Ezzetabi6.0
Run code in Different compilersNaren Varma6.0
Prefer pre-increment and pre-decrementKarl6.0
Pointer arithmetic trickinessvishesh jain6.0
Test pieces of your code earlyHardi Pertel6.0
Understanding the win32 data typesMuhammad Shahid6.0
Reuse Old CodeTimofei Gerasimov6.0
Rounding a floating point number to a near-fractionSteven6.0
Dynamic memory allocation of 2d arraysnandam6.0
Make backupsVox6.0
Tips for writing programs for beginnerspradeep6.0
Modifying const variablesWiro Sableng6.0
String to integerMayur Avhad6.0
Use const variables as function parameters when pobeyonddc5.9
Use STL containers instead of C arraysSang-drax5.9
Executing system commandsSean5.9
Turn on all compiler warningsMaragato5.8
Always check for NULL (in C)Webmaster5.8
Use multiple filesThantos5.8
Use <constant> == <value>Webmaster5.8
Goto vs. Higher-level control structuresSean5.7
Commenting out code with the preprocessorWebmaster5.7
Use templates to prevent memory leakageKunal5.7
Don't use fflush(stdin)Shakti5.7
Use the Appropriate VariablesMahesh Kumar.S5.6
beware of loop invarinatsIain5.6
Member Functions are inline by default (C++)Ash5.6
Avoid memory wastageArthi5.6
Get a copy of the standardThantos5.6
take advantage of array indiciesDave5.6
pre & post increment & decrement operatorsjay5.6
Turn off optimization when debuggingAshok Kumar5.5
Doing calculationsLinuxguru5.5
Make pointer and reference arguments constAkshay5.5
Comment!VOX5.5
Give Proper Names to Your VariablesMaragato5.5
char *pa; and char a[];avdtech5.5
Indent your ProgramPrashant Sahay5.5
match the out side world ideas to logical designinmady5.4
Put braces around if statement code, part 2PING5.3
Compiling 32-bit code on a 64-bit machinevinay Kumar5.0
Cute but dangerous code, finding the larger integer without using comparisonsPrakash Samy5.0
Don't modify a variable more than once in a single statementGanga R Jaiswal5.0
Operator Associativity and HierarchyAvinash5.0
What is pointer arithmetic?Umer khan4.6
Decompose before you codeAbhinandan Pandey4.5
finding size of variable without using sizeof()Rajesh punia4.0
swap with out using temporaryraghava4.0
Arguments for MainSajan3.7
Automatic Array initialisationkedar3.7
creating a messagebox on WindowsAmarjeet Kawathe3.5
Check the return value of scanf( )citizen3.2
Be careful of Magic behaviour due to compilersmanik3.0
increment and decrement on pointerRAJKUMAR3.0
Checking if two arrays are equalUnnikrishnan T A0.7
Assigning a char array to another char arrayBrian Plummer0.5
Increment and decrement counters with rolloverLee Walker0.0
Using _strtime and _strdate to get the timeAli Jafar0.0
One instruction per lineLudovic Flender0.0
Use preincrement with iteratorsDirk Tjantele0.0
Use virtual functions instead of type checkingSajan0.0
Why you can't dereference a void* pointerashish mathur0.0
Don't increment the same variable multiple times in one statementsidra0.0
Never return a non-const pointer to a data member!hussain hani0.0
Display Date and Time in C++Govind0.0
Long variable namesCarl0.0
take care while using new and deleterajender0.0
Operator precedence shortcutsai shanker0.0

Saturday, 3 December 2011

Protect your data


USB flash drives are convenient, portable, and very easy to lose. Which is a problem, especially if they're carrying sensitive data. Fortunately Windows 7 has the solution: encrypt your documents with an extension of Microsoft's BitLocker technology, and only someone with the password will be able to access it. Right-click your USB flash drive, select Turn on BitLocker and follow the instructions to protect your private files.
Bitlocker
PROTECT YOUR DATA: Your USB flash drives can easily be encrypted with BitLocker

Pin a drive to the taskbar


The taskbar isn't just for apps and documents. With just a few seconds work you can pin drive icons there, too.
Right-click an empty part of the desktop, select New > Text File, and rename the file to drive.exe. Drag and drop this onto your taskbar, then delete the original file.
Right-click your new "drive.exe" taskbar button, then right-click its file name and select Properties. Change the contents of both the Target and Start In boxes to point at the drive or folder of your choice, perhaps click Change Icon to choose an appropriate drive icon, and you're done - that drive or folder is now available at a click.
DriveC

Customise the log-on screen



Changing the Windows log-on screen used to involve some complicated and potentially dangerous hacks, but not any more - Windows 7 makes it easy.
First, browse to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background in REGEDIT, double-click the DWORD key called OEMBackground (not there? Create it) and set its value to 1.
Now find a background image you'd like to use. Make sure it's less than 256KB in size, and matches the aspect ratio of your screen as it'll be stretched to fit.
Next, copy that image into the %windir%\system32\oobe\info\backgrounds folder (create the info\backgrounds folders if they don't exist). Rename the image to backgroundDefault.jpg, reboot, and you should now have a custom log-on image.
Alternatively, use a free tweaking tool to handle everything for you. Logon Changer displays a preview so you can see how the log-on screen will look without rebooting, while the Logon Screen Rotator accepts multiple images and will display a different one every time you log on.

Friday, 2 December 2011

Windows Tricks and Shortcuts


Startup Screen

  1. Create a 320x400 bitmap in the root directory and name it LOGO.SYS
  2. You can use LOGOW.SYS file in the Windows directory as a starter
Logoff Screens
  1. There are many system file that constitutes Lofoff screen.
  2. They are actually bitmaps 320x400 that just have a different extension
  3. The hidden file in the root directory LOGO.SYS is the startup logo.
  4. There are two files in the Windows directory.
  5. LOGOW.SYS is the Wait while Shutting down ... screen.
  6. LOGOS.SYS is the You may now shut-off or Reboot screen.
  7. Make two new image files of your chice in Paint and name it as LOGOW.SYS and LOGOS.SYS and replce the actual windows file by this two.
  8. But make sure they should be of the same size

Lock a folder in windows XP

To Lock a folder in windows XP without any software. Follow the steps Below.
  1. Make a Folder in C drive rename it as "abc" without quotes.
  2. Now open Command Prompt from Start Menu.
  3. Type "attrib +s +h C:\abc" without quotes and press enter.
  4. This command will Make your folder invisble and it can not be seen even in hidden files and folders
  5. To make it visible again type "attrib -s -h C:\abc"
  6. You can lock any other folder also by changing the location C:\abc to address of your folder.

Magic Bottle Trick


Effect: 

The magician asks for a volunteer from the audience who looks inside a bottle to make sure it's a normal, empty container. 
The volunteer returns the bottle and then examines a magic wand to ensure it is normal. 
The magician drops the wand into the bottle (noting how easily it falls in).
He/she turns bottle over and lets go of the wand.  
The wand magically remains suspended in the bottle.

Supplies:

~a magic wand (could use a pencil instead) that is taller than the bottle (when you drop the wand into the bottle, part of it should still be sticking up through the opening.
~a bottle that has an opening large enough to fit the wand in (but not too big).  The bottle cannot be see-through
~an eraser
If you don't have a bottle that is dark, you can put some dark paint inside the bottle and shake it around so the inside is painted.
Cut a piece off the eraser, just large enough to wedge the wand into the opening of the bottle.  The eraser is what makes the trick work!

Secret:

Pass the bottle to the volunteer and ask them to make sure its empty.
Take back the bottle and give your friend the wand.  Meanwhile, slip the piece of eraser into the bottle without anyone seeing (you can have it in your pocket until this point).   You'll need to practice this a few times.
Take the wand back and drop it into the bottle.
Pick up the wand and bottle and turn them VERY SLOWLY upside down (mumble all sorts of enchantments while you're doing this).  Pull on the wand slightly when the bottle is turning over so the piece of eraser gets wedged into the opening (you'll need to practice this a few times too).
Let go of the wand... PRESTO!  It doesn't fall out.
Slowly turn upright again.  Let go of everything and PRESTO the wand remains suspended in the bottle (it doesn't fall back down).
To remove the wand, push it slightly to release the rubber and then take it out.