23 Archived Topics

Remove Filter
Member Avatar for Narue

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.

Member Avatar for The Old Man
19
2K
Member Avatar for Narue

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 …

Member Avatar for Smn
18
13K
Member Avatar for Narue
Member Avatar for Narue

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 …

4
366
Member Avatar for Narue

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 …

Member Avatar for Narue
3
378
Member Avatar for Narue

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> …

Member Avatar for dusktreader
7
2K
Member Avatar for Narue

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 …

0
279
Member Avatar for Narue

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 …

0
1K
Member Avatar for Narue

A fairly complete implementation to provide another perspective on a seemingly simple program.

Member Avatar for Ene Uran
0
146
Member Avatar for Narue

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 …

Member Avatar for easternRAT
2
342
Member Avatar for Narue

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 …

Member Avatar for majestic0110
1
361
Member Avatar for Narue

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 …

Member Avatar for Matt Labbé
1
1K
Member Avatar for Narue

## 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 …

Member Avatar for Ancient Dragon
23
7K
Member Avatar for Narue

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 …

Member Avatar for ivailosp
1
680
Member Avatar for Narue

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 …

Member Avatar for bector
2
8K
Member Avatar for Narue

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 …

Member Avatar for Duoas
2
178
Member Avatar for Narue

>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.

Member Avatar for WaltP
0
255
Member Avatar for Narue

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 …

Member Avatar for Bench
0
498
Member Avatar for Narue

[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 …

19
3K
Member Avatar for Narue

Since C and C++ are different languages, would it benefit Daniweb to split the C/C++ forum into separate C and C++ forums?

Member Avatar for Electrohead
0
609
Member Avatar for Narue

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 …

Member Avatar for Dave Sinkula
0
146
Member Avatar for Narue

Since Dani refuses to post, and you people should care enough about the community to follow the log closely, I attached it. ;)

Member Avatar for Dani
0
343
Member Avatar for Narue

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 …

Member Avatar for Narue
0
546

The End.