2,322 Reusable Code Snippet Topics
Remove Filter ![]() | |
This is a simple balloon shooting game made in C language. In this game, there are number of balloons, a bow and arrows for shooting the balloons. The balloons rise from the lower portion of the screen. The bow is put on left side which can move up and down. … | |
This program searches the given txt file.And tells you how many there are. Just a reminder don't forget to put the searced txt file in C: or change it accordingly for more info or questions [email]Silver.Lost.Raven@gmail.com[/email] have fun!! | |
Obtaining user input can be done in many surprisingly different ways. This code is somewhere in the middle: safer than [inlinecode]scanf("%d", &n)[/inlinecode], but not bulletproof. It is meant to be a simple but relatively safe demonstration. The function [inlinecode]mygeti[/inlinecode] reads user input from the stdin into a string using [inlinecode]fgets[/inlinecode]. … | |
This snippet shows how to use the functions [inlinecode]time[/inlinecode], [inlinecode]localtime[/inlinecode], and [inlinecode]strftimetime[/inlinecode] to pick off only the time parts for display. | |
Some issues with date/time calculations. [Perhaps I ought to edit this one day and better describe it.] | |
To check for integer overflow, you can't simply check the [i]outcome[/i] of an operation, you need to check [i]before[/i] the operation. So how do you do that? This example checks for overflow with multiplication. | |
This is yet another example of reversing a string. This version modifies the original, reversing the string in place. [I]See also [url=http://www.daniweb.com/code/snippet522.html]Strings: Reversal, Part 2[/url][/I]. | |
This problem is a typical homework question. The code presented here may contain some elements that may be a little "ahead of the game" in coursework, but it presents some of the basic elements that might be used in such an exercise. | |
A common way to represent an inventory is with a list of tuples. Each tuple represents the item name and the item count. You can sort this inventory list by item name or item count. Here is an example to pick a sort key. It's your summer job to run … | |
Where you ever curious what the most common letter is in a typical text file? Just another question to ask a friend. The answer is right here in this tiny code snippet. The program converts the text to all lower case letters, and then list them out alphabetically showing the … | |
This code uses field level validation to check for data in fields in an Access form, and instead of using message boxes (as the "Validation Rule" and "Validation Text" properties of a field (in the table design window) do, it turns the associated label and control (textbox/listbox/combobox) background color to … | |
Place the file with part one of the code on the server. This part of the code gets placed in a batch file (text file with the extension *.BAT) and placed on each client's machine. Again, you will need to change the paths used to the real paths on your … | |
This code snippet will attempt to show newbies to php how to connect and retrieve data from a PostgreSQL Database Server using PHP. | |
Learn how to loop anything you want sertain number of times. In this example im gonna show you a simple next and loop that changes the font size. | |
This is a neat little script that will tell you how many active users you have on your site. You do need a webhost that supports the global.asa file! Most free hosts dont. [B]Code From: [URL="http://http://www.iportalx.net"]http://www.iportalx.net[/URL][/B] | |
It is a small two-in-one calculator that can work as a regular or RPN calculator, selected by a RPN checkbox. It has a four level stack similar to the HP 48 calculator made from four Tmemos. This code shows you how to make visual effects(RPN stack) from existing delphi components. … | |
This is the first program I wrote, well besides Hello world. I put about a lot of hours into this code, it started as a divisional calculator than i evolved it so it would ask your name and calculate your average and i was messing around with the system ("") … | |
This is a bit more tough than it sounds. well some one gave me this problem and I found this tricky not until I used recursion. | |
There are numerous calls to Win32 API that return detailed information as to failure via GetLastError (). I've devised a method by which to get the textual information corresponding to error and the address of the call that caused the violation. If GetLastError () returns null, then it can serve … | |
The module datetime allows you to call several functions that can do computation with dates and times. How many days since my birth? How many days till Xmas? What's the date 77 days from now? The code snippet should give you a flavor, enough to explore on your own. | |
Many of the code samples on the internet are written in Turbo C. The clrscr() function litters these samples, and even to this day people want to wipe your screen. You can use system("CLS"), but that uses a DOS command. DOS commands are with us only at the whim of … | |
Quick and dirty way to change your console program colors using DOS command "Color BackgroundForeground" where Background is hex 0 = black to F = white, dito for Foreground. | |
The wxPython library allows Python to create Windows GUI programs. Here is a look at the listbox component. Click a button to load the listbox with names, select the name by clicking on it on the list, and display it in the title bar of the window frame. Another button … | |
This program uses WinApi function SetPixel() to plot math functions y = sin(x) and y = cos(x) and y = sin(x)*cos(x) along a y-axis centered on the console screen. Make sure that gdi32.lib is included in the libraries to be linked. | |
Just a simple way to separate the words contained in a sentence. As an option you can store the words in a vector. If you are not familiar with a vector, use an array instead. | |
I look at BCX-basic as a modernized qbasic. This simple code creates a Windows GUI program that plays a midi instrumental music file. To keep it simple, the file it looks for is "TheRose.mid" file. If you don't have this file, you have the option of editing the code, or … | |
Shows how to connect a button onclick event to a javascript function to change the background color of the document. Just cut and paste the code into Notepad or other editor, save as BGchanger.htm and run it on your browser. | |
Remember the Spirograph? It used geared circles to create some rather artistic geometric designs. This program uses triangles to follow in the Spirograph's foot steps. The math is rather simple, just a couple of sine and cosine functions, also the ubiquitous for loops, everything wrapped up in the using() statement. … | |
A Simple Function To Generate A Random Password Of A Given Set Of Characters | |
The set is an unordered collection of unique hashable elements. All the elements/items in a set are treated as keys. There are several functions that compare two sets. Right now, I will just give you a taste ... | |
A fairly complete implementation to provide another perspective on a seemingly simple program. | |
A very rudimentary more, press enter to view next screenful of text, like with print command in ed text editor. | |
Similar to cat in unix textutils. You can actually edit files with these. Remember that ctrl-z sends end-of-file in windows, and ctrl-d in linux. | |
Text fragment extractor (usage: fragment /pattern/[n] [/pattern/[n]] file), similar to the print command in ed and vi, with pattern range. If the second pattern is omitted, prints to the end of file. Use quotation marks when there are spaces in the argument. Finds the first pattern, then the second pattern, … | |
The code shows you how to create a window without a titlebar that can be dragged with the mouse. Set the FormStyle property to fsStayOnTop. The form contains a small 18 button calculator. When you create the form and calculator components, try to make it tiny, it is cute that … | |
Using wxPython and the Boa Constructor, a VB/Delphi like IDE and Visual Builder, this little calculator was a breeze to make. Boa did 90% of the code generation, and I simply added code to each button click event to make the calculations work. I wish every project would go that … | |
Chargen is a program created entirely by mahen of Mauritius. The simple task of Chargen is to generate characters, but the most important aspect of this particular program is it's abillity to process user input. Due to the way the program was programmed, any input that the user will make … | |
![]() | Unlike a balanced skip list, a probabilistic skip list uses random numbers to determine the height of each node rather than deterministic logic. The only real advantage of using a linked structure instead of an array based structure is in code maintainability. |
![]() | Array based skip lists are a pain to work with. They are error prone and difficult to follow. Worse, they are difficult to extend so that the data structure is deterministic rather than probabilistic (a desirable property). The following implementation uses a linked structure instead of arrays for the levels. |
A program that reads in two integers and determines an prints if the first is a multiple of the second. | |
A program used to calculate each employee's pay based on that employee's paycode. | |
A program that inputs three integers from the keyboard and prints the sum, average, product, smallest and largest of these numbers. | |
Find all Pythagorean triples for side1, side2 and hypotenuse in which all sides are no larger than 500. Use a triple nested for loop that tries all possibilites. | |
A program that asks the user to enter two numbers, obtains the two numbers from the user and prints the sum,product,difference, and quotient of the two numbers. | |
Uses only integers for monetary values to calculate compound interest. | |
Uses the string comparision functions and the techniques for sorting arrays to alphabetize a list of strings. Uses the names of 10 or 15 towns in your area as data for the program. | |
A test program that will call the PROC findGCD, passing in the integer values input by the user and then it will display the results to the screen. | |
A program that will test the Nonrecursive Factorial procedure using a value passed in by the program user and will also do a time comparision of the Nonrecursive and Recursive Factorial functions. |
The End.