Software Development Code Snippet Index

C#
2

Event Handler Tutorial

How to Handle Events Event handlers make up a large portion of Windows Form Coding. There have been a lot of questions on the C# forum of late that stemmed from people creating Event Handlers incorrectly. First lets look at how an event and its event handler works: Each event is a piece of... (Read More)
1

How to make your controls moveable?

Here's I wrote some code to move controls on the form 1- Assign (Control_MouseMove, Control_MouseDown, and Control_MouseUp) to the controls you need it movable. (Read More)
2

Drop-Down TreeView Control (faking it)

Overview: Oddly enough, MS never created a TreeViewDrowDown or equivalent. What I mean, is a control that looks and acts like a ComboBox, but contains a TreeView instead of just a list when in the expanded drop-down mode. I've never understood why they haven't, but I always seem to want to... (Read More)

Experiments with a ListBox (C#)

I am afraid, I am starting to like C#, despite the somewhat bloated .Net Framework requirements. Mister Bill's Microsoft is very supportive though. The language has a nice flow compared to GUI programming in C++. Here we are looking at a standard ListBox, add some items, sort them and select... (Read More)

Very simple console barchart

Well, I don't think I can make this any simpler. I hope newbies in the C# language can learn from it. (Read More)
1

Bouncing ball

Wanted to let two forms work together. One form would be the input form and the main form would consume this data. I managed to succeed with the help of a few of my friends here at daniweb., who helped me setup a static form. Just posted a bit of the most relevant code here, the rest of the... (Read More)

Plotting with Pylab

You can download the matplotlib free from: http://matplotlib.sourceforge.net/ It has, amongst many other things, the module pylab that allows for high quality plotting of data. All you have to do is to feed it a list of x values and the corresponding list of y values calculated from the x data... (Read More)
1

Sorting complicated objects (Python)

This code snippet shows you how to sort more complicated objects like a list of lists (or tuples) by selecting an index of the item to sort by. (Read More)

A context to change current working directory.

This snippet defines a context to execute a block of statements in a different working directory (with the help of the with statement). After the block is exited, the initial working directory is restored, even if an exception has occurred in the with block. (Read More)

Connect 4 - make_board

Hi Folks the game runs. jippie, but i have a small problem i cant get the board to get drawn from left to right, its drawn from upwards to downwards hope anyone can help me Sincerly elomanias (Read More)

Getting an input without hitting enter

!USING PYTHON 3.1! USING WINDOWS I never thought it could be so simple. However I should have clarified that it's a 1 character input. But the general idea is the same. Someone suggested that I explain what is going on better, so I'm going to do that. The function 'getch()' waits for a... (Read More)
2

Really Simple PlugIns Loader - Import all modules in a folder in one swoop

PlugIns in their simplest form can be just python modules that are dropped into some designated directory and dynamically loaded by the main application. This snippet can be used to do just that. Usage To load plugin modules: >>> plugins = importPluginModulesIn('mypackage') >>> plugins... (Read More)
1

how to use getpass in python

#! /usr/bin/env python #filename:pwd.py # development environment:python2.51 import getpass usr=getpass.getuser() while True: (Read More)
1

Wordcount of a text file (Python)

A simple program to count the words, lines and sentences contained in a text file. The assumptions are made that words are separated by whitespaces, and sentences end with a period, question mark or exclamation mark. (Read More)
2

Singletonize any class

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 absolutely... (Read More)
C++
1

BubbleSort and Insertion sort

The simplest sort, although inefficient. Below is a demonstration of bubble sort and insertion sort. The bubble sort just consists of 2 for loops and std::swap. The insertion sort uses 2 loops as well but not as much swap as bubble sort. Any questions ? (Read More)
2

i need help

Hello everyone i'm a new member , i need ur help with this code , i want to write a for loop that assigns the 3rd row of the array to 0,, and then print out the array after setting the 3rd row to 0. (Read More)
4

Adding two Big string numeric integer

The function adds two large numeric string together, like "12345667" + "12345678" = ? It does not have complete error checking, I'll leave that up to you. It should work but I am prone to bugs, so do advise if bugs are found. Included are also helper function that helps us add the large... (Read More)
1

How to access map outside the class

#ifndef _READFILE_H_ #define _READFILE_H_ #include<string> #include<vector> #include<map> using namespace std; class Readfile{ (Read More)
2

musician needs basic help

Hello i am a musician and not a programmer. i assume this is completely obvious to you by now. do listen to my music if you please. something to do while you read my long enquiry. samantha.mp3 I am attempting my first c++ program to create a program for a midi control device..... a... (Read More)
2

Play a MIDI voice (Dev C++ console program)

You can access the sound chip to play midi voices using winmm.lib, or in case of Dev C++ the libwinmm.a library. There are 128 midi voices to pick from, anything from the Acoustic Grand Piano = 0 to the Gunshot = 127. (Read More)
2

reverse queue

I am given the class definition of stack and queue classes where I have to write a templated function called reverseQueue(?) that takes a pointer to queue as a parameter and uses stack object to reverse the given queue. The function call to reverseQueue should reverse the data of the passed as a... (Read More)

Reference Variable

What will be the value of "++n" in the above code? Pls help.. (Read More)
1

Binary Tree Question

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. (Read More)

searching linux directories

I previously posted an MS-Windows example program about how to recursively search folders and create a list of their filename. This program is similar in concept but is for linux. It c++ and uses std::string and std::vector classes to hold the strings. When the program encounters a directory... (Read More)
C
1

Linked List

This is just a linked list program for those who need help understanding the fundamentals. Put comments if you find some bugs. The program is about maintaining a student database (their roll number and their age) I've used Turbo C++ 4.5 as the compiler :icon_cool: (Read More)

Binary to Decimal Conversion

The computer is a binary beast. We want to go from the one-fingered digital box to the ten-fingered human being and convert binary to denary(base 10) numbers. This is how it works, for instance, binary 10010 is calculated as 1*16+0*8+0*4+1*2+0*1 = decimal 18. Just because it's easy, let's throw... (Read More)
2

Permutations of String using recursion

This program was written and tested in unix/linux environment (in EMacs editor )with a GCC compiler. (Read More)
1

can any one help me about calculating the exact execution time of processor

hi, Can any one help me about clock problem..i need to calculate the exact execution time of algorithm using the processor clock speed not the wall clock time..i am getting zero by using the clock_t function in time.h.also how can i calculate the exact processor speed execution of... (Read More)
1

fseeko64() and ftello64() for deal with large files (eg. file dimension)

fseek() and ftell() work only for files < 2,147,483,647 bytes fseeko64() and ftello64() from <stdio.h> can deal with files up to 18,446,744,073,709,552,000 bytes the printf format for unsigned long long val is %I64d eg. Obtaining the file dimension (this code was tested with GNU GCC... (Read More)
2

Tower Of Hanoi ( Graphical Illustration )

The famous Tower Of Hanoi with graphics and animations. (Read More)

toupper and tolower implementation for whole c-strings

This is a toupper and tolower implementation for whole c-strings, without making use of the existing toupper and tolower functions for characters :) example: char s="Hello, beautiful world!"; stoupper(s); // s now contains: `HELLO, BEAUTIFUL WORLD!ยด stolower(s); // s now contains: `hello,... (Read More)
-7

List Windows Logical Drive Letters

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

Changing the contents of a file

I'm working on a program to score a bowling game. Right now, my terminal says that my program has a seg fault, but I can't tell where. Any other insight on how to help my program do what it's supposed to do would be helpful. I'm still not sure how to weed out all the characters, although I think... (Read More)
-1

errno - perror vs fprintf + strerror

Hi! From the manpages I know, that perror evaluates the errno. So using perror and fprintf + strerror, as coded in my example below, should result in the same error messages, but they do not. The execution of the program leads to the following result: bash> ./errno_test blub fopen()... (Read More)

Windows Event Handler in MASM

This procedure dispatches application defined event handlers and alternately executes default process for both standard or sub/super classed windows. Map is defined as follows. In most cases I define this table in .data, but in can be in .const also. I choose writeable memory as application... (Read More)

a86 Palindrome

Hey guys.. need some help with this; I'm pulling my hair out.. i've trawled these boards but can't find anything that answers my question. I, like many others before me (so it seems!) am trying to create a program to check for a palindrome.. this is what I have so far. In the compare part..... (Read More)

Save, Edit, Delete Data using VB.Net and SQL Server 2000

This code to save, Edit and delete data in VB.Net using SQLServer as backend. this code is continuance from my previous post "Show Data in DataGrid with VB.Net 2003 and SQLServer 2000". so i didn't write code how to connect SQLServer 2000 with VB.Net 2003 cause this already in there. Please see... (Read More)

Sample code for taking user input from Shell

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. (Read More)

Count the words in a text string.

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

Forum Tools


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC