1,916 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
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.

Software Development c++
1
244
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 …

Software Development python
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.

Software Development gui java
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.

Software Development 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 …

Software Development image visual-basic
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.

Software Development c
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 …

Software Development python
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.

Software Development
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

Software Development c++
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

Software Development visual-basic
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.

Software Development visual-basic
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 …

Software Development perl
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

Software Development pascal
Member Avatar for sobari
0
1K
Member Avatar for wavsyntax
Member Avatar for niXman
-1
100
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.

Software Development c++
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 …

Software Development c++
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 …

Software Development c
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 …

Software Development c
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 …

Software Development c
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.

Software Development
Member Avatar for maryann2076
0
160
Member Avatar for clarence_cool03

{-='Reads ten integers and prints the first and the last on one line using Dev-C LaNGuaGe'=-}

Software Development c
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.

Software Development printer visual-basic
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.

Software Development python
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 : …

Software Development image visual-basic
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 …

Software Development encryption visual-basic
Member Avatar for MATRIX123456
2
1K
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.

Software Development pascal
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 …

Software Development java
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 …

Software Development c# ide
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.

Software Development c++ motherboards-cpu-ram
Member Avatar for VernonDozier
0
1K
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...

Software Development microsoft-access visual-basic
Member Avatar for azadohy
-3
266
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.

Software Development python
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).

Software Development python
Member Avatar for bumsfeld
1
621
Member Avatar for sudhansugupta

This is a scheduling algo based on round robin scheduling.

Software Development c
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]

Software Development c c# c++
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 …

Software Development c display
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.

Software Development assembly
Member Avatar for unimo
0
4K
Member Avatar for warbird43

Stack Intersection by Fraz Jamshed

Software Development c++
0
355
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 …

Software Development c++ python
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 …

Software Development java
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 …

Software Development apple python
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 …

Software Development c file-stream
0
210
Member Avatar for nirveshverma

HEy:) Buddies in early morning i want to calculate that exchange during download & you very well known that it is shown in byte so just i am g with c++ and play a game for writing this. thanks enjoy it. It's very easy and handy with simple logic.

Software Development c++
Member Avatar for tkud
1
5K
Member Avatar for EDDYGATE

The code below captures the screen and saves it. Depending on your need, you can modify it to do just what you want [code] import java.awt.AWTException; import java.awt.Robot; import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.io.*; import javax.imageio.ImageIO; class ScreenCapture { public static void main(String args[]) throws AWTException, IOException { …

Software Development image java
Member Avatar for firstsmilepk
0
238
Member Avatar for Gaiety

/* difference between %i ad %d %i reads the value and it recognizes the value as what base it is when we read the value as 023 (base 8) it is 19 (base 10) and 0xa(base 16) it is 10 in (base 10). */ OUTPUT: /* Enter a number:023 Out …

Software Development c
Member Avatar for Ancient Dragon
1
161
Member Avatar for Ghost

The source of my COPYRIGHTED tictactoe java game. It shows how to use multiple classes, methods, etc.

Software Development java
Member Avatar for JamesCherrill
-2
133
Member Avatar for mnemtsas

Here's possibly the single most useful function that I use. It simply takes an ADO record set and dumps the column names and row values into an Excel worksheet. To use it make sure you have Excel marked in your project references.

Software Development visual-basic
Member Avatar for chad0809
1
547
Member Avatar for mostafadotnet

This is somewhat a simple project I wrote by getting help from google groups I always recommend. assemble this code using this command: [QUOTE]nasm -o 1.com 1.asm[/QUOTE]

Software Development assembly
Member Avatar for wildgoose
0
456
Member Avatar for tkud

This code draws different shapes to the screen,(in this version, only a square or a cross. It will be updated soon!!). This code was written by a beginner, for the beginners!!

Software Development c++
0
190
Member Avatar for toraj58

[I]The FileSystemWatcher class is phenomenally powerful—and staggeringly simple.[/I] Start up a new Windows Forms application. Then drop FolderBrowserDialog, FileSystemWatcher, label, listbox, and button controls onto the form. [B]Setting up Properties:[/B] Set up the name properties of the controls; the button is called chooseButton, the label is folderLabel, the list box …

Software Development
Member Avatar for nenadnikolic
1
389

The End.