2,322 Reusable Code Snippet Topics
Remove Filter ![]() | |
Hello here i am posting the non recursive or no recursion implementation of outputting [B]Permutations of a string [/B]as compared to the recursive implementations previously posted. Any feedback, constructive criticism or comments are most welcome. | |
The C++ [i]string[/i] type can be converted to a [b]const[/b] null-terminated string using [icode].c_str()[/icode] for interoperability with legacy C code. However, this poses a potential problem when mixing [i]std::string[/i] with functions designed to mutate a string in-place. a const_cast to get around this issue results in undefined behaviour, since the … | |
We are all tired of from our daily lives. So I suggest to sit back and play this game. I present here a hangman game( text version ) for your enjoyment. There might be some bugs as I haven't throughly tested it, so sorry if you find it( I'm sure … | |
I used this code to store convert pictures to "[COLOR="Red"]binary[/COLOR]" inoreder to save in database but it stores only one picture from two pictureboxes. let someone show me how, you can convert pictuers in two seperate [COLOR="Green"][B]'picturebox ("picturebox1 and Picturebox2")'[/B][/COLOR] using the function in the code snippet on something similar. … | |
A program that handles either piped input (command/prog | your_prog) or file redirected (your_prog < file_name) input. Determine whether such input exists before issuing a stdin read so that the program does not go into a "waiting for input" state. Written in/for the XP environment. | |
[B]Background[/B] I was looking for a simple control in wxWidgets which I could use to plot out [i]some value[/i] against time, but I found that apparently I was the only one that needed that kind of graph. (so I don't know why I'm posting it... but anyway). I decided to … | |
This function will take a string and convert it into a folder/file friendly name. I use it in conjunction with url rewriting, deriving the filename from the title of an article. | |
If you have done a PHP based website, chances are you have dynamic content called by variables and so on. As many people use a main page (index.php) and use code within that page to dictate what content is displayed, either with if or switches or whatever. Thing is, Google … | |
[B]Introduction[/B] In this sample,It shows how to move files to another folder. [B]Background[/B] It can be used in winForm applications. | |
Ever wondered how to calculate the date of easter? Well here is how to do it in C# | |
NOTE: ~this code is in c++ ~you need not change anything in the code ~the commented lines are there just in case you want to see how the program works in real time - simply uncomment them and run the program, these commented lines are not necessary for the program … | |
This snippet defines a class OptCmd which adds line and options parsing capabilities to the python standard lib's cmd.Cmd class. It allows you to quickly write an extensible command line interpreter. To use this module, you will need [url=http://www.daniweb.com/code/snippet234768.html]this other code snippet[/url], saved as a module named 'argv.py'. Enjoy the … | |
Some time ago, I was writing a small command line interpreter, with the help of [url=http://docs.python.org/library/cmd.html#module-cmd]the standard module cmd[/url] which offers minimal support for such tasks, and I had the problem that this module doesn't have a function to parse a command line to produce a list argv which can … | |
OK here is a piece of code I've been working on that actually logs you in and returns what ever Curl sees except i have no idea how to make Curl function correctly with websites that require cookie authentication correctly, can anyone help? =/ | |
Hope some one can assist me Below is my code which works fine. I need to be able to select more than one of the options at the same time. The code at the moment will only select one option rather than all my options. Any advice would be great. | |
Assembles under NASM 16-bit, invoke INT 0x65 to display message. | |
Intended as a replacement for [URL="http://www.daniweb.com/code/snippet217322.html"]this[/URL] old crap of myself ;) Note: no error checking provided, if you need it, then you can easily implement it yourself :) | |
I am developing a code to find the occurence of digits in a string. I need help. When it compiles I get the error: cannot find symbol variable countDigits | |
Wallpaper or tile images are small images that can be spread across a background repetitively. A common practice on web pages. The surface created with wx.PaintDC() can be used for this effect and still allows other widgets to be put on top of the wallpaper. The small tile image is … | |
In this snippet of code, I am trying to check the customers request against the volume remaining in the tank. If the request is greater, I need to instruct the customer to move to the next tank. But I am having problems. The tank is set to store 100 gallons. … | |
Hi, The code below will check if a particular exe is running in windows, return the Process ID and force kill the process. If anybody has an easier way to do it please feel free to comment :) | |
A lotto simulator with a twist, you pick the winning numbers and the computer buys the lotto tickets. Anyway, the computer at least generates the tickets and checks how many of them would match the winning numbers you selected. Let's assume you would be the state lotto commissioner and your … | |
Hello sir, I tried with this code it is running well but I am not getting mail in my account with this code, even this code is not giving any error. Is there any problem?? Please help me. | |
the code takes each character and stores where and how many times a roman numeral appears and the assess the integer. this is my first code im posting. anything to make the code better is most welcome. roman numeral refers to M=1000 D=500 C=100 L=50 X=10 V=5 I=1 and uses … | |
hi i was set the task to increment a number by x every x seconds and i tried to find some [URL="http://www.daniweb.com/code/../techtalkforums/thread68355.html#"]code[/URL] off the net, but found the subject covered very sparsley so for whoevers benefit ill post the code here hope it helps [URL]http://www.daniweb.com/code/../techtalkforums/dani-images/smilies/fiyellow/icon_smile.gif[/URL] Thanks Nicholas | |
The password salt (the byte array) can be any random collection of numbers - so long as it matches in both the encrypt and decrypt methods. Also - the same password key needs to be used in both encryption and decryption. | |
A very simple PHP/Javascript snippet to detect the resolution of a user's monitor and create a table using that resolution to best fit within the user's browser (to avoid scrolling). Note: This is a PHP script which includes Javascript | |
The idea for this came from another thread in the C++ forum that wanted to duplicate the _getdelim() function that is supported by GNU compilers g++. I made one major change in that this version does not allocate new memory every time it is called, which is grossly inefficient. Instead, … | |
here is how the code works. small but powerfull. this code will unblock the command prompt of any system that has been disabled. Just open your NOTEPAD, then type in COMMAND.COM .. then save the file using the extension " .bat " example igwe.bat then run the program .. enjoy … | |
This snippet provides 2 functions to create in memory a gziped archive of a sequence of files and directories, and to extract files from this archive. These functions are similar in effect to the linux commands [icode]tar czf[/icode] and [icode]tar xzf[/icode] but instead of writing an archive file on disk, … | |
This code should be able to get you started to design 2-D scrolling games, like Mario. I spent a few hours trying to figure this out, and firgured I'd put up my efforts. I think there might be a better way to do it, but this should help you get … | |
This is a snippet that takes a min value, max value and how many random numbers from the user then, after it checks to make sure it's not already in the list, adds the new random number to a List.. I hope it helps you..... :) | |
I needed a way to buffer into memory an entire wav sound file to be played back a moments notice, as if for a game. So i created this class, simple instantiate it by passing to it a string and a bool indicating if you should buffer it to memory. … | |
The program uses an implementation of the Sieve of Eratosthenes to generate a small list of prime numbers which is subsequently used for direct comparison to find the prime factors for any whole number up to and including 478939. This limitation is due to the primitive method used to generate … | |
Hi, This will show you how to create a login form using swing. Please be aware that this form does not connect to anything. ( eg. A URL or a database) This is just a little advanced example of one of the many things you can do in swing. A … | |
Convert a decimal (denary) integer to a binary string. An exercise in do ... while and while loops. | |
i have created lines in graphwin but i did it the long way is there a simpler way using loops ? cheers | |
Some background. We all used the string class, but some of you might not know that string is just a typedef of basic_string. In fact here is the typedef you might find when looking in the XString library. [code] typedef basic_string<char, char_traits<char>, allocator<char> > string; [/code] This code snippet shows … | |
This code defines a new operator new in C++ such that the memory returned is in the shared memory segment rather on the heap. This code exists to prove a point. "Objectifying" shared memory. One can not overload the new operator but one can overload operator new. Reference the C++ … | |
Hello, I've been working on this self-made database. What do you think about it? What features should I create for it? I'd also like to get help in a select method, because I don't have the foggiest idea how it could be done. And what about making it a database … | |
This one is a messaging system! Made it myself, works great! Hopes you like :) | |
The program generates a calendar for one year. The program only asks for the day on which 1st January falls from user. Notes : [LIST] [*]Compiler - Turbo C++ 4.5 [*]Leap year has been considered [*]The only reason for including [icode]conio.h[/icode] is because of [icode]clrscr()[/icode]. If somebody can give me … | |
| |
this code was written by me for my projects. all it does is increments by 1 the string which is passed to the function. if you have any improvements to my code ill be glad to hear from you ;) | |
need this to change to random colors every .8 secs. compiles ok, but not getting wanted results. cant figure out where i am wrong? i get the applet viewer window with a black square but no color change. Here is the .html file <applet code = ColorChange .class width = … | |
I wrote this code to load the image on mouse click...but it is not displaying as soon as i click the mouse...i need to resize the jframe to make that visible what is the problem with this.......please anybody ans for this....thank u in advance... | |
![]() | Hello, Can anyone help me solve the error in this program?? I get the following error: [COLOR="Red"] Exception in thread "main" java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at converter.main(basic_convert.java:20)[/COLOR] The whole program runs properly. The error come after asking if I want … ![]() |
HI ALL, i am writing this snippet to working with text files, here i explain the basic functionality of read/write operation on text files.....:) Here each method has a single parameter, the file name you wish to work with. | |
If you drop a picturebox control onto a form and set its SizeMode to zoom you will notice that no matter what you change the padding property to, it won't change the output. The code for drawing the image in zoomed mode doesn't take in account the deflated rectangle it … | |
Several methods of reversing the bits of a byte are presented here. [i]Note that not all of the methods are portable.[/i] |
The End.