2,322 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
Member Avatar for Ancient Dragon

This demonstrates how to get a list of your computer's logical drive letters under the MS-Windows operating system.

Member Avatar for Ancient Dragon
2
929
Member Avatar for Wong23

Can someone help me with this problem here about Binary Trees. I was given this code... and I am required to write a function void count_nodes(?) to determine the total number of nodes in a Binary Tree.

1
244
Member Avatar for marulu

I am in the process of learning PHP with JS and Ajax and have the foll. problems. I have created a class to generate master data entry screens. (1) Javascript code that works when I run master.class.php independently does not work when I run users.php. I came across this problem …

0
145
Member Avatar for pythopian

This is one simple way to emulate a singleton class on behalf of a normal class. (A singleton class is a class with at most one instance.) The implementation does not emulate a class 100% (for example it lacks the special attributes lile __dict__ or __bases__), but it should be …

2
235
Member Avatar for aj.wh.ca

Sample code for taking input from Shell demonstrating string and int input For simple programs or testing purpose its not always required to take input thru GUI.

Member Avatar for javaAddict
0
239
Member Avatar for vegaseat

A function that takes a string and returns the number of words in the string. An example of using pointers in Pascal.

Member Avatar for BitFarmer
0
2K
Member Avatar for srikanth48

Type BITMAPFILEHEADER bfType As Integer bfsize As Long bfReserved1 As Integer bfReserved2 As Integer bfoffbits As Long End Type Type BMPInfoHeader biSize As Long biwidth As Long biheight As Long biPlanes As Integer bibitcount As Integer biCompression As Long bisizeimage As Long biXPelsPerMeter As Long biYPelsPerMeter As Long biClrUsed As …

Member Avatar for vb5prgrmr
0
328
Member Avatar for arsh_arsh

need to replace all occurences if substring by new string. below code replace first occurence but not other substrings present in input string.

0
251
Member Avatar for vegaseat

Python can use its COM support and the OCX of the WindowsMediaPlayer to play mp3 music files. Make sure that your Python installation has the win32com folder. Check [url]http://starship.python.net/crew/mhammond/win32/Downloads.html[/url] for the latest win32com support. [COLOR="Red"]This code relies on file WMPlayer.OCX which MS has removed on newer versions of Windows. See …

Member Avatar for vegaseat
1
2K
Member Avatar for vckicks

A simple way to check if the current C# program is the only instance of itself running.

Member Avatar for ashishkumar008
1
256
Member Avatar for arpit.mishra

Hi, I tried to direct the output from a thread into a log file using fstream, but it dosent seem to work. If I use ostream then it works fine. Can you please let me know why fstream is not working. Thanks in advance

1
246
Member Avatar for naveen g

i run vb6.0 code in xp for getting hdd physical id and it run ok. but when i run same programme in vista it does not display any hdd physical id. please solve the problem

Member Avatar for naveen g
0
183
Member Avatar for cookware_ok

Easily allows temporary message to be displayed on any label for a programmable length of time. This is a very simple way to display a temporary message on an existing label (or textbox)without doing a lot of coding.

Member Avatar for muzaffar85
0
318
Member Avatar for mitzoff

I'm new to perl and I'm writing a script to parse multiple Gaussian03 output files and extract certain pieces of data from them. Ideally the script needs to print out the name of each file, look for (the last) SCF Energy, the Zero-point Energy and check if the job has …

Member Avatar for mitzoff
0
207
Member Avatar for FlamingClaw

This small program shows that how we can arrange strings by alphabet in a vector.By FlamingClaw

Member Avatar for sobari
0
1K
Member Avatar for wavsyntax
Member Avatar for vegaseat

This shows how to create, load and access a ListBox. BCX was used to create the original code which was then modified to work with the Dev C++ (really GCC/G++) compiler, compile as a Windows Application.

Member Avatar for lashatt2
0
1K
Member Avatar for William Hemsworth

Here's a function that manually converts an integer to any base between 2 and 36, the parameter list is: [CODE]void toBase( int value, // Integer value to convert char *target, // Pointer to a large enough buffer int base, // Base (from 2 to 36) int fixedDigitCount // The minimum …

Member Avatar for William Hemsworth
0
213
Member Avatar for panagos

Just another way to check if a word is palindromic or not. In my country (Greece) if a word is palindromic we say it is "καρκινική" that's why i named the fuction in the code kark(). -What it does? If we would say that word has n letters,then this compares …

0
239
Member Avatar for Iam3R

I am very poor in calculating complexities. Please some one let me know what is the complexity of the below program. I actually want to write a program for finding the nth last element with 0(n) complexity. but unable write, please give me some idea. the below code works perfectly …

0
298
Member Avatar for alien2006.happy

This code is just handling the SIGCHLD signal, but as you can see, the parent process should ignore this SIGCHLD signal according to the signal function. But in fact, the parent process will omit the signal function, and handling the child process using "wait". I wonder why the parent do …

0
154
Member Avatar for vckicks

The xor operator allows you to switch the values of two integer variables without the need for a third, temporary variable.

Member Avatar for maryann2076
0
160
Member Avatar for clarence_cool03
Member Avatar for ravishkkumar
0
137
Member Avatar for AndreRet

Let you choose between all printers available on your pc or network. Download zip and enjoy. Royal free.

1
995
Member Avatar for Gribouillis

Printing a convenient [url=http://en.wikipedia.org/wiki/ANSI_escape_sequence]ansi escape sequence[/url] clears the terminal (if you're running python from a terminal). Similar techniques could be used to print in colors.

Member Avatar for Gribouillis
0
278
Member Avatar for Vineeth K

Hello friends i made a small program like a scanner it will scan an image file to a Rich Text Box. My friend helped me in providing the code to access the pixels of an image.Hope you will like the code. Try it .... This need : Reference files : …

Member Avatar for Riju Thomas
0
332
Member Avatar for Jx_Man

This is code for Encrypt and Decrypt. this a simple logic of encryption. Please leave comment or feedback if this code helps you. Thanks. Jery. :) the encrypt function place in a module. This Code needed : 1 Module 1 combo box (For input before encryption) text1 in this program …

Member Avatar for MATRIX123456
2
1K
Member Avatar for alxwm
Member Avatar for DealthRune

This is a nice and easy table editer. Use it to add and delete cells, rows, and a caption

Member Avatar for Jonh S. Brown
1
160
Member Avatar for Lord Soth

Note that the angle is in 1/10 of degrees. Any attempt to manipulate font.size or font.color will reset the angle to zero degrees.

Member Avatar for Vector Khanal
0
239
Member Avatar for sravan953

This code snippet allows you to know whether a word/sentence you have entered is a 'Magic Word' or not. A 'Magic Word' is a word which has at any position two consecutive letters. This can be achieved by taking the ASCII values of the characters. For example, if I enter …

Member Avatar for rnthelord.2008
0
6K
Member Avatar for vegaseat

A small Windows Application to show you how to play a wave (.wav) sound file. I am using the C# IDE from SharpDevelop and the runtime dotnetfx 1.1 from Microsoft, both free downloads. This forms a small and fast student system to write and debug C# programs. From there you …

Member Avatar for ashley dane
0
1K
Member Avatar for sfuo

This program asks for integers from the user and stores them into a multidimensional array that adjusts its size.

Member Avatar for VernonDozier
0
1K
Member Avatar for DealthRune

Use this to encrypt your passwords, for login fields and password protection.

Member Avatar for LUCKYLOVE
0
303
Member Avatar for rhenerlau

This code is to split a Microsoft Access database and re-connect it on launch so that you can use Access on a multi user network...After Splitting the database manually, place the following code in the form that launches when the database is launched...

Member Avatar for azadohy
-3
257
Member Avatar for masterofpuppets

A simple function to return the number of occurances of a letter in a text. An easier way to implement this would be by using a dictionary :) P.S sorry if there already is a code snipped like that somewhere.

Member Avatar for lrh9
1
765
Member Avatar for Gribouillis

This snippet shows a fast and efficient way to cut strings in substrings with a fixed length (note that the last substring may be smaller).

Member Avatar for bumsfeld
1
621
Member Avatar for Drew

I created this code because i was bored and wanted to try something with some code and i ended up creating this little code snip. [B] Code from: [URL]http://www.iportalx.net[/URL][/B]

Member Avatar for yonker
0
198
Member Avatar for msaqib

This is a small function that will block the specific IP from viewing the certain page, and it will redirect the user to the main page or noaccess page.

Member Avatar for yonker
0
324
Member Avatar for sudhansugupta
Member Avatar for briane010
3
166
Member Avatar for tux4life

A small function which reverses a c-string by just swapping the elements :) ... Usage:: [CODE=C++] char[] str = "hello"; reverse(str); // str now contains "olleh" [/CODE]

Member Avatar for Nick Evan
0
1K
Member Avatar for banders7

Displays which partitions are on which physical hard drives and shows partition starting offset and length. Developed and tested under XP using a Borland C++ compiler. Code is not provided for the private includes, but changes to make to code work are trival. References to werrtxt() and format() can be …

0
508
Member Avatar for Dani

This is a program I wrote for my x86 assembly class which computes the sum of n numbers. It uses Irvine32.inc which came with the textbook.

Member Avatar for unimo
0
4K
Member Avatar for warbird43
Member Avatar for vegaseat

Python has some powerful functions, like the math expression evaluator eval(). You can embed this function and others in your Development C++ code. All you need to do, is to download and install the free Python Development Pak and feed the Python code in the form of a string to …

Member Avatar for Shantha.D
1
5K
Member Avatar for nirveshverma
Member Avatar for azwraith69

Hello... This is my naval battle game so far.. Just search i t if you're unfamiliar with the game it is only player vs computer.. can you adjust/fix my code so that: -the player is able to place his ships by means of dragging the JLabel ships at the left …

0
769
Member Avatar for masterofpuppets

this is my version of the popular snake game. The snake is controlled by the mouse so be careful when you start :) it grows infinitely long...you should download the apple.jpg file for the game, or graw one of your own just name it apple.jpg and place it in the …

1
360
Member Avatar for banders7

Code written and tested using the Borland C++ compiler. Code uses access() to determine if an input string exists either as a directory name or as a file name. If access() fails, the string is neither a file or directory and the function terminates. If it does exist, the name …

0
210
Member Avatar for corewizard

The End.