2,322 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
Member Avatar for clarence_cool03
0
143
Member Avatar for clarence_cool03
Member Avatar for Dave Sinkula

This is a quick and dirty example of a hex dump utility. Not much in the way of special features -- it just dumps the contents of a hard-coded filename in hex and also shows the characters. An example that can show the basics of making your own.

0
233
Member Avatar for tux4life

This program can solve expressions of the following forms: [ICODE]a+b[/ICODE],[ICODE]a-b[/ICODE],[ICODE]a*b[/ICODE],[ICODE]a/b[/ICODE] ([ICODE]a[/ICODE] and [ICODE]b[/ICODE] are numbers :P) Notice: You can't put spaces in between the operands and the operator, I know this is a limitation and that there are thousands of other ways to achieve a better result, so please don't …

Member Avatar for tux4life
0
177
Member Avatar for NicAx64

This is not the fastest way and not the one that used inside the calculators and even inside the C++ math library. But this is just another way to find logrithm of base 10.

Member Avatar for ddanbe
0
105
Member Avatar for aiswariya

A game... Depends fully on luck that u have and a little bit of smartness.. You will be given 3 chances.. and 3 nos will me running randomly. u have to click when all t three no are same.. if u succeed in this then u are t winner.. Smart …

0
103
Member Avatar for aiswariya

This is very very simple c code.. it has simple maths logic involved..

0
98
Member Avatar for aiswariya

The program is exactly to work out with maths fun.. u think of a two digit no.. say 24 now add both the digits i.e;2+4=6. subtract 6 with the no tat u thought originally.. i.e;24-6=18.. see t symbol which correspond to the no 18 and then press enter to see …

0
163
Member Avatar for VernonDozier

This snippet is similar to my snippets on how to create random numbers without repeats, particularly[URL="http://www.daniweb.com/code/snippet1034.html"] this one[/URL]. This snippet is different in that it takes an already existing array and "shuffles" it so that the order appears random. No checking is done to make sure that there are no …

1
776
Member Avatar for tux4life

Probably one of the poorest sorting algorithms ever written but I provide it here and anyone who wants to use it can use it in any way he/she wants :P ... Usage: `bubble_sort(your_array, number_of_elements);` int arr[] = {52,85,2,1,-56,802}; bubble_sort(arr, 6); /* order of elements in arr: {-56, 1, 2, 52, …

0
153
Member Avatar for tux4life

> I know there are some bad things in my code such as [ICODE]system("CLS");[/ICODE] and that this makes the code unportable and inefficient, but you could just remove it at anytime :) > It could be that my code is a bit bloated, I didn't put enough time and effort …

Member Avatar for tux4life
0
259
Member Avatar for puneetkay

This program consists of a function in one class. It demonstrates the "Left To Right" Principle used by most of the languages.

0
110
Member Avatar for William Hemsworth

This snippet basically shows you how to input a password from the user without actually displaying the characters, instead they are replaced with the ' * ' character as you type. The code is uncommented, so I will briefly explain it. This function: [ICODE]void PasswordInput(char *password, size_t maxLength)[/ICODE] has two …

0
525
Member Avatar for William Hemsworth
Member Avatar for William Hemsworth
0
744
Member Avatar for meghs007

This program take user name and password from the use but the password not display on screen insted of password ***** display Program by Meghdoot(meghs)

Member Avatar for burnt-ice09
0
194
Member Avatar for GANTOR
Member Avatar for Nick Evan
0
144
Member Avatar for FlamingClaw

I want to show a simple example about writing record to a file,and for checking,read back from that file. Created By FlamingClaw

0
258
Member Avatar for leegeorg07

this is code that thanks to vegaseat helped me convert my programs into python30

0
181
Member Avatar for MosaicFuneral

"Hello World!" done a little differently. Is this safe, unlikely; is there a point to all of this crap, nope; why are parts obfuscated, because I felt like it; was it fun, yes. You'll need the newest version of MinGW to compile, I used options -O2 -Os -s.

Member Avatar for MosaicFuneral
0
357
Member Avatar for MosaicFuneral

Got bored, remember a question asked in the forums, and decided to try something similar.

Member Avatar for MosaicFuneral
0
9K
Member Avatar for kelechi96

Hi this basicly finds and stores prime numbers at you will need to put a file called startnumber.ini with a number in it for the program to start from. Also rename the UserStorage.txt each time you use the program or it will be overwriten.

Member Avatar for William Hemsworth
0
242
Member Avatar for GreenDay2001

The given code snippet checks whether a given string is a part of other string and wildcard are allowed.

0
115
Member Avatar for FlamingClaw

This algorithm will add the searched element's place in an array This works only when there is so element what we're searching for. By FlamingClaw

0
155
Member Avatar for FlamingClaw

This algorithm will decide that is there a serched element in the array.If it finds one then the loop halts.If the loop halts cause we're stepping over the last element of the array then there is not searched element. By FlamingClaw

0
2K
Member Avatar for FlamingClaw

Counts that how many propertied elements are in the array example:negative numbers By FlamingClaw

0
176
Member Avatar for FlamingClaw
0
802
Member Avatar for tux4life

Hello, as promised I updated my stod-function from [URL="http://www.daniweb.com/code/snippet1147.html"]this[/URL] thread ... Enjoy !

Member Avatar for tux4life
0
553
Member Avatar for tux4life

Hi there, I've written a program which can add two numbers of unspecified length, isn't that nice? To add two numbers you just do the following: [ICODE]addition(number1, number2);[/ICODE], where 'number1' and 'number2' are strings ... E.g: [CODE=cplusplus] ... cout << addition("500","10") << endl; // Print '510' on the screen ... …

Member Avatar for tux4life
0
269
Member Avatar for FlamingClaw

Prime or not?This little program will show prime numbers with green color from 0 to 100.By FlamingClaw;

0
293
Member Avatar for ddanbe

Although the DateTime structure in .NET has an IsLeapYear method. Lots of people in here like to do this on their own. See this snippet on how it can be done. This is in C# but other language adepts might benefit from it also.

0
178
Member Avatar for tux4life

Hello, I've written a C++ class which 'estimates' the roots of a given number ... It was called 'sqr' because it was first intended to estimate square roots only, but later on I made some little changes to my code which made it possible to estimate every root ... So, …

Member Avatar for tux4life
0
185
Member Avatar for niladri.saha06
Member Avatar for MosaicFuneral
0
240
Member Avatar for MosaicFuneral

A quick way of spying inside of a process. You could also turn this into something like a disassemble, pretty easy, if you wanted too. Quick Notes: The inline assembly is GCC dependent(quick fix for other compilers), and in MinGW you need to link th32 and gid32. The code flow …

0
462
Member Avatar for tux4life

Hello there, I've written a C++ function 'stod', which converts a C++ string to a double ... You're free to use this code for EVERYTHING you want ... There's only one thing which I'm not appreciating: [B][COLOR="Red"]It's not allowed to sell this source code to anyone ![/COLOR][/B] The usage is …

Member Avatar for tux4life
0
4K
Member Avatar for rahul8590

Well , i have created a simple chatting interface . i would not call it a chatting interface actually cuz i had something else in my mind and finally landed on something else . i would like if you guys could excecute it and help me making it a real …

Member Avatar for toyi
0
280
Member Avatar for lllllIllIlllI

This is a simple program and all it does is fiddle with the registry and set the value of the desktop background to be the bmp file that you supply in the function. There are other things you can do with the windows registry, this is just one of the …

Member Avatar for shadwickman
0
253
Member Avatar for ddanbe
0
814
Member Avatar for alpschints

ADODB.Field error '80020009' Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. /nirmal/asp/editrecord.asp, line 0

0
317
Member Avatar for serkan sendur
Member Avatar for banders7

Here's some rudimentary code that does directory traversal recursively. Useful for inspecting the contents of a directory subtree. Sorting the directory information or inspecting file details within directories is beyond the scope of this routine.

0
260
Member Avatar for FlamingClaw

I want to show you some rules about bit operating like Not,And,Or,Xor,Shl,Shr... By FlamingClaw

0
199
Member Avatar for Hiroshe

This code snipplet will find the placement of each letter in a array(string), from another array(character set). For example: the input would be something like this: string[256] = "gfdc" chrset[256] = "abcdefg" and the output would be: num[256] = 6, 5, 2 and 3

Member Avatar for Hiroshe
0
119
Member Avatar for FlamingClaw

I've seen,there are guys that did not know,where to use a unit... See it just reference By FlamingClaw

0
783
Member Avatar for verruckt24
0
351
Member Avatar for FlamingClaw

This little program a solution for putting a string into an array. The method is that the string is divided for chars.... By FlamingClaw

0
214
Member Avatar for FlamingClaw
0
199
Member Avatar for FlamingClaw
0
974
Member Avatar for FlamingClaw

Often there is a case when we want to fill an array with record,and this program will demonstrate it...

0
217
Member Avatar for FlamingClaw
Member Avatar for FlamingClaw

The End.