23 Archived Topics
Remove Filter Just for fun, I wrote up a quick tutorial for basic assembly. At present, it's only in the form of a PDF document, but I'll eventually get around to adding it to my website. | |
When you want to remove extraneous characters from an input stream in C++, it's usually because you mixed formatted and unformatted input methods. The formatted method would leave a newline in the stream and the unformatted method would consume it and terminate successfully, but fail completely to do what you … | |
This is an example of using a binary index file to speed up random access of lines in a file. The file is indexed one time, where the position of the start of each line is stored in an index file. Subsequent requests for a get the position from the … | |
In answer to a coworker's question today about memory management today, I wrote the following code. It's an implementation of the gets function that accepts an infinite length string (bounded only by the heap) and [i]does not[/i] force the caller to free the resulting pointer. I figure that it's a … | |
Consider the following program and input file: [code] #include <algorithm> #include <cstdlib> #include <ctime> #include <functional> #include <fstream> #include <iostream> #include <iterator> #include <string> #include <vector> #include "natural_compare.h" struct natural_less: std::binary_function<std::string, std::string, bool> { bool operator()(const std::string& a, const std::string& b) { return natural_compare(a, b) < 0; } }; std::vector<std::string> … | |
FASM can output an executable PE directly, but sometimes you want to output an object file for linking with modules in other languages. The following program can be used to link with the C library of the GCC compiler with the following commands: C:\>fasm hello.asm hello.obj C:\>gcc hello.obj -o hello.exe … | |
Some languages are hard to get started in. FASM appears to be one of these languages because the documentation is not detailed enough for a beginner. That's a shame because FASM is (in my opinion) one of the better assemblers. The following snippet is a simple Hello, world! program which … | |
A fairly complete implementation to provide another perspective on a seemingly simple program. | |
This code demonstrates AVL insertion and deletion. The code was originally written in C by myself a little while back for a tutorial. The translation to Java was fairly trivial, and to add a little excitement I even threw in a few generics. Yes, I'm aware of this line: tree.data … | |
Insertion sort, Selection sort, Bubble sort, Shell sort, Quicksort, and Heapsot. All optimized and ready to be experimented with. This is the framework for a Java application that speed tests various sorting algorithms (because there's usually little need to write one's own in production programs). Several popular algorithms were left … | |
This quicksort implements the basic recursive algorithm with three improvements. The first improvement is choosing the pivot based on the median of three values in the list to be sorted. This minimizes the chances of a worst case scenario. The second improvement speeds up the algorithm by termination when subfiles … | |
## Before You Ask ## - Read our [Forum Rules](http://www.daniweb.com/community/rules). - Engage your brain! We understand that running into a problem can turn off the rational centers of the brain, but please sit back and think for a bit about your problem before running off to find help. All too … | |
Here's a challenge for you C++ aces. The challenge is to write a function with the following declaration: [code] unsigned long extract_digits ( unsigned long x, size_t n, size_t i ); [/code] This challenge has three parts. [B]Part I (Beginner):[/B] Write the extract_digits function. It should return a sub-value of … | |
Post your tips for making life easier in C and C++. I'll start: [SIZE=3][B]Standard vector object initialization[/B][/SIZE] The biggest problem with the standard vector class is that one can't use an array initializer. This forces us to do something like this: [code] #include <iostream> #include <vector> using namespace std; int … | |
I've been writing my own implementation of stdio.h whenever I get a few spare minutes recently. Nothing fancy or thorough, and without wide character support, it's hardly conforming. But I was looking at one of my intermediate versions of printf and could only marvel at how ugly it was. So … | |
>How can i convert a number to binary in c++ If you stare at it really hard, things will start to blur and when you turn your head, it'll start to look like binary in your peripheral vision. | |
Let's pretend that I'm interviewing you for a C++ job. I want to know how you[1] approach problems and the extent of your C++ prowess, so I'm going to ask you to solve short problems in C++[2]. These problems range from beginner to advanced, and may be more than they … | |
[B][U]Before You Ask[/U][/B] [list=1] [*][B]Engage your brain![/B] We understand that running into a problem can turn off the rational centers of the brain, but please sit back and think for a bit about your problem before running off to find help. All too often a little common sense is all … | |
Since C and C++ are different languages, would it benefit Daniweb to split the C/C++ forum into separate C and C++ forums? ![]() | |
For those of you who don't know, Daniweb has an IRC server. I'm there a lot, and I don't see any of you. That's not good because I'm there, of course. Real time chat with the resident guru ([B]shamless[/B]) will make you smarter ([B]utterly shameless[/B]) and cooler ([B]words cannot express … | |
Since Dani refuses to post, and you people should care enough about the community to follow the log closely, I attached it. ;) | |
Just for fun, I threw this together by modifying and adding to a simple language definition posted here recently. Since everyone hates me, I'll give you a chance to snipe at my first draft. :D The code is long enough to be an uncomfortable post, so I'll attach a zip … |
The End.