DeanMSands3 69 Junior Poster

For reference: http://en.wikipedia.org/wiki/AVL_tree
I remember having touched these briefly in my CS Fundamentals 3 class, now some 5 years ago. Haven't touched them since.

Does anyone use these on a semi-regular basis and in what context?

DeanMSands3 69 Junior Poster
DeanMSands3 69 Junior Poster

Sarkund has a good answer, but let me add to that.

Sometimes there are external dependency issues like audio codecs that aren't immediately obvious. I believe SFML has some.
Keep an eye out for those.

DeanMSands3 69 Junior Poster

Granted. The Storm Troopers allow you and your Gungan padawan to pass unharmed.
I wish I could forget Emo Vader's "NOOOOOOOOOOOOOOOOOOOOOOOO..."
(Honestly, if Lucas had saved that catharsis just seconds before the mask went on, I would broken down in manly tears.)

DeanMSands3 69 Junior Poster

If you really want to convert the number to a string, you can do this:
Since you're using the Borland Turbo Programming set, you could write a simple snippet in Turbo C without using any of the libraries, then turn on Assembly generation when compiling.

This will give you an assembly code file you can use as a reference.

DeanMSands3 69 Junior Poster

Here, lmgtfy.

Moving the text cursor:
http://lmgtfy.com/?q=dos+interrupt+text+cursor
Site found in 10 seconds of visual scanning
http://www.ece.msstate.edu/~reese/EE3724/labs.old/lab6/desc.pdf

Printing the time.
http://lmgtfy.com/?q=bios+interrupts+21h
Site found in 10 seconds of visual scanning:
http://www.shsu.edu/csc_tjm/spring2001/cs272/interrupt.html

DeanMSands3 69 Junior Poster

Here's the code rewritten in a readable format. The main task is still incomplete.

#include<iostream>
#include<cstdlib>
#include<pthread.h>
using namespace std;

const int m=6;
const int n=5;
const int s=5;
const int r=8;
const int number_of_outer_threads=3;

class Matrix{
    int *dataArray;
    int rows;
    int columns;
public:
    Matrix(int new_rows, int new_columns){
        rows=new_rows;
        columns=new_columns;
        dataArray=new int[rows*columns];
    }
    void fill_array(){
        for(int i=0;i<rows*columns;i++){
            dataArray[i]=rand()%10+1;
        }
    }
    void display(){ //Yes, this would have been better as an ostream. Bite me.
        cout << "[" << rows << "*" << columns << "]="<<endl;
        for(int i=0;i<rows;i++)
        {
            for(int j=0;j<columns;j++)
            {
                cout << this->get(i,j) << "\t";
            }
            cout<<endl;
        }
    }
    int get(int i, int j){return dataArray[i*columns+j];}
    void set(int i, int j, int d){dataArray[i*columns+j]=d;}
    int get_rows(){return rows;}
    int get_columns(){return columns;}
    bool can_multiply(Matrix *that){return this->columns==that->rows;}
};

typedef struct {
    Matrix* A;
    Matrix* B;
    Matrix* C;
}DataSet;

typedef struct{
    DataSet *pDataSet;
    int startRow;
}
ThreadOuterPackage;

typedef struct{
    DataSet *pDataSet;
    int currentRow;
    int column;
}ThreadInnerPackage;


void* multiply(void* pod)
{
    ThreadOuterPackage *top=(ThreadOuterPackage*)pod;
    DataSet* P=top->pDataSet;

    for(int i=top->startRow;i<m;i+=number_of_outer_threads)
    {
        ////////////////////////////////////////////////////
        // VV      This block needs to be threaded     VV //
        ////////////////////////////////////////////////////
        for(int j=0;j<r;j++)
        {
            float sum=0;
            for(int k=0;k<n;k++)
                sum+=P->A->get(i, k) * P->B->get(k,j);
            P->C->set(i, j, sum);
        }
        ////////////////////////////////////////////////////
        // ^^      This block needs to be threaded     ^^ //
        ////////////////////////////////////////////////////
    }
    return NULL;
}

int main()
{
    Matrix *A=new Matrix(m,n);
    A->fill_array();
    Matrix *B=new Matrix(s,r);
    B->fill_array();
    ThreadOuterPackage **threadOuterPackages=new ThreadOuterPackage* [m];
    DataSet* mainDataSet=new DataSet;

    if(A->can_multiply(B))
    {
        Matrix* AB=new Matrix(m,r);
        pthread_t tID[number_of_outer_threads];
        mainDataSet->A=A;
        mainDataSet->B=B;
        mainDataSet->C=AB;

        ////////////////////////////////////////////////////
        // VV    Use this block as a reference point   VV //
        ////////////////////////////////////////////////////

        for(int i=0;i<number_of_outer_threads;i++)
        {
            threadOuterPackages[i]=new …
DeanMSands3 69 Junior Poster

@happygeek: I remember seeing an article for these some 15 years ago when I was in high school. The article reviewed these exactly as you described - high wow-factor, but not very usable. (You might have even written the article.)

Was wondering if they were ever going to come back.

DeanMSands3 69 Junior Poster

Gonna post another one:
Bon Jovi: Bells of Freedom
@diafol: Nice! I keep forgetting to check when they come to town.

DeanMSands3 69 Junior Poster

I'm trying to remember the name of a site - pretty sure it was a wiki - where you post different ways of writing the same program in different languages.
I. E. writing "Hello World" or heap sorts in C, C++, Java, Haskell, etc.

My google-fu is failing me, so I was hoping someone here would remember.

Lend me a hand, Daniweb?

DeanMSands3 69 Junior Poster

@Hiroshe: I think you mean Cairo for #10, but otherwise, +1! for a nicely comprehensive list.

Myself, most of my UI work is in GTK with a brief stint in MFC, but I've always wanted to do Qt. Unfortunately, I'm easily distr- ooh! What's that?

DeanMSands3 69 Junior Poster

Matchbox Twenty/Mad Season

diafol commented: M20 - saw them with Bon Jovi in 2001 - really good +0
DeanMSands3 69 Junior Poster
DeanMSands3 69 Junior Poster

Let me pull this snippet from a previous post of yours:

    mov si, offset string
    mov     al, [si]
    cmp     al, 'a'
    jl  noconvert
    cmp     al, 'z'
    jg  noconvert
    sub     al, 32

This will actually work well in deciding which characters to convert.
You will still need to plug the converted value back in as you're doing in your above post.
But you also need to change where your second loop starts.
And you still need to check for the delimiter character to exit the loop and carry on.
Happy coding!
(Comment your code.)

DeanMSands3 69 Junior Poster

Dear Young Sir,
Allow me to impart some valuable advice to you. This wisdom will no doubt be instilled within your malleable young mind in years to come, but you would be so much more blessed to receive sooner as opposed to later.
Permit me to make this humble suggestion for your betterment and coding enrichment:

COMMENT YOUR !@$% CODE

Or when you can, use self-documenting code which is not so easy in assembly, but some people manage.
Now, as to your dilemma, the answer was simple after I read your code and referenced external material.

    mov si, offset string
    mov     al, [si]
    cmp     al, 'a'
    cmp     al, 'z'
    sub     al, 32

This is where you should be making your adjustments. You need to go through each character and identify if it is an actual lower case letter. If so, you subtract 32 as you're doing. Then mov the value back to [si] then increment the offset si. But you have to loop.
The loop ends when you come to the '$' terminator. This will require a cmp and je combo. And since the labels "top" and "stop" have already been used, you'll have to pick different labels for your loop.

EDIT: And once you're done, you'll need to print out the new string after line 45 (the last print command), but before 47 (the program terminator).

Good luck on your homework.

DeanMSands3 69 Junior Poster

Well darn. Thanks, @Hiroshe.

DeanMSands3 69 Junior Poster

I've found that there are times when I need to pull down a repository, but when working with other people, there's always that certain file that holds particular user-specific customizations. We need to pull it down the first time, but every time afterward, I'd prefer it not get updated - pushed or pulled.
Is there a way to do this?
EDIT: Maybe I should use a hook script to download the file once? Forgive my GIT noobishness.

DeanMSands3 69 Junior Poster

I'm going to follow Ancient Dragon's lead on this one. (Never mind my Monty Python link from earlier.)

Yo mama carried you for nine months. Thank her for that.
Yo mama put up with your 25-hour sleep cycle. You owe her big.
Yo mama didn't strangle you when she had the chance. I guarantee it: you gave her reasons.

This Mother's Day, tell yo mama you love her.

DeanMSands3 69 Junior Poster

Once upon a time, I read somewhere in a book (whose name escapes me) that to PROPERLY validate an email address, the regex was somewhere in the neighborhood of 200 lines of code. (It probably has something to do with all the country domains.) That number has probably gone up since then.
I passed that bit of trivia to a fellow coder, but realized I couldn't source it.
It's probably locked away in a Perl function somewhere, but I don't know Perl nor the Perl community. (Or that could be a red herring).
In any case, does anyone here have any recollection to that effect and where I could source it?

DeanMSands3 69 Junior Poster

How are you at remembering to garbage collect and release unnecessary resources? You'll build the application faster in Java. You'll run the application faster in C++. That's been argument for years. Pick one.

DeanMSands3 69 Junior Poster

Using the definition that any technology sufficiently advanced is indistinguishable from magic, C style strings are far less magical than C++ strings.
With a C++ string, the sky (or rather, your protected allocated process memory space) is the limit. Need a bigger string? That's A-OK. We'll just allocate more memory for it.

A C string, like your buffer, example1 and example2, are arrays of characters that fit in their designated spaces. When they overrun the amount of room in their designated spaces, bad things happen. With example1 and example2 , the size isn't defined in code, so the compiler assumes you're fine with it allocating ONLY as much space is needed to hold those particular strings plus their respective trailing zeros (all C strings end with a 0 byte). Your buffer string is 78 characters plus a zero making for a required size of 79. You can strcat a string that's 1 letter long to it, and that's all.

So what if you want to make it bigger? Well, you have to pre-plan and give it a bigger size e.g. buffer[100] or example1[256].

Or you could rewrite to do dynamic allocation and resizing, but don't worry about that just yet.

EDIT: This is a crappy explanation, and I'm not sure I got the point across. Please ask questions if this is unclear.

DeanMSands3 69 Junior Poster

Just a follow up to add a few suggestions.

As far as graphics, there are several free graphics repositories open to use. Just Google them (like "character sprite generator"). As far as quality goes, YMMV.
Sounds and music are also freely available. Have a look at NewGrounds' Audio portal and get permission from the artists you like.

As far as coding, Ancient Dragon is right. C++ is a great language to use, but not a good one for a beginner coder.
I'd recommend Python with the "PyGame" library. Python is an easy-to-learn, easy-to-use language, and PyGame is the Python implementation of libSDL - sort of like DirectX with training wheels (but much much more).

When you get a solid mastery of what you're doing, I suggest moving on to either Java or C#.NET. Both have libSDL implementations, and both are still easy to learn, but not as easy as Python. This will give you a better feel for the bigger stuff.

If you really want to move up, and the other stuff hasn't scared you off, move to C++ for some real raw power. But be aware: C++ is not forgiving. Missed semi-colons are minor distractions compared to linker errors. It gets really rough. But stick with it, post questions to forums, Google for help shamelessly, and you will persevere.

DeanMSands3 69 Junior Poster

Hey, DaniWeb! I need your opinions.

I'm looking to expand my skillset, particularly in the Windows department. On a scale of "Eh, maybe later" to "Do it! Do it now!" what is your opinion on the importance of learning PowerShell as opposed to another life skill like Haskell, Mandarin Chinese, or subtropical gardening?

Or if you have other suggestions, I'm open to them.

DeanMSands3 69 Junior Poster

See above, but here's a little advice too.

Pick a programming language.
Write a podcast ripper in that language.
Add in multithreading to download multiple files at once.
Add a GUI.
Add playback for the completed files.
Use whatever libraries you need.
Lather. Rinse. Repeat.

(Hm... I still need to do this for C++.)

After time, you will be really sick of podcast rippers. But you'll understand how to create network connections, download text files, parse XML, use concurrency, download binary files, display said files in a GUI, and play them - in the languages you picked out.

And maybe you don't want to do a podcast ripper. That's fine. Pick a different project with multiple parts.

Last and MOST important, hang on to your code. You WILL need it in the future.

DeanMSands3 69 Junior Poster

Maybe this will illuminate you.
This site studies the top programming languages by usage.
http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
C is #1. (As it should be.)
Guess who's #2?

DeanMSands3 69 Junior Poster
  1. One do loop needs to enclose the other.
  2. The variable in the inner loop (perhaps counter) needs to reset to zero everytime the outer loop starts.
  3. After the inner loop, print a "\n" (This starts a new line.)
  4. The inner loop variable (counter)needs to be less than the outer loop variable (counter2) which in turn needs to be less than the input variable (integer).
  5. This is much easier to do with for loops, but I'm guessing you're stuck with do-while.
DeanMSands3 69 Junior Poster

Potentially useless anecdote: When I was studying for my Bachelor's, I took a class called Programming Languages (later to be replaced by compilers). The subject of study was an obscure multi-paradigm language called Oz (with it's equally obscure IDE, Mozart).
For one of the last assignments, I had to write a Fibonacci function. Being that the Fibonacci series reuses its values, I wrote a function that stored values in a dictionary. Then, instead of a long painful O(n^2) wait, Fibonacci(500) was done in milli-(micro?)seconds.

DeanMSands3 69 Junior Poster

Granted, but you went too far in the "Airing of Grievances".
There is now a law-suit pending.

I wish that I'd get over this cold, that my new medication wouldn't keep me awake until the sun starts coming back up (apparently 9am is too late to take it), and that I could think clearly enough to finish my past-due work projects so I can spend time with mine and my wife's families this Christmas instead of holing up in the guest bedroom coding, suffering from a headache, while my wife tries to please both of our families.

DeanMSands3 69 Junior Poster
DeanMSands3 69 Junior Poster

Beat me to it again!
I'll just add that itr isn't directly affected by i, so the first run through when itr is at the beginning, itr-1 is pointing at something that's not there.

DeanMSands3 69 Junior Poster

Now, I'm not a terribly smart man, but on line 17, wouldn't you be trying to print the value property of the Integer that itr points to?
EDIT: Beat me to it!

DeanMSands3 69 Junior Poster

I learned pointers from Snowman's rewrite of Denthor's VGA Trainers.
Fire up a copy of DOSBox with a retired copy of Turbo C 3.0 and go here now.
http://www.hornet.org/cgi-bin/scene-search.cgi?search=Denthor

If you have strong stomach and won't downvote me for it, Stanford released a set of videos...
http://cslibrary.stanford.edu/104/

DeanMSands3 69 Junior Poster

You can't beat the classics. https://www.youtube.com/watch?v=cAy4zULKFDU

DeanMSands3 69 Junior Poster

The quick fox brown jumped over the lazy dog. When asked why, the fox said "Because I could."

DeanMSands3 69 Junior Poster

Ender's Game

DeanMSands3 69 Junior Poster

STAR TREK: THE MOTION PICTURE

DeanMSands3 69 Junior Poster

Granted. http://memegenerator.net/instance/42837643
I wish there were more hours in the days.

DeanMSands3 69 Junior Poster

Hey Daniweb! What's a good site, or maybe someone could write up a quick-and-dirty example of a desktop app showing how to use the Model View Controller pattern?
I'm no slouch at google-fu and found this lovely example through Wikipedia: http://www.songho.ca/opengl/gl_mvc.html
which I'll look at after class tonight. I'd still like any examples you could provide.
Thanks, Daniweb!

DeanMSands3 69 Junior Poster

Well, if you removed the data types from where you call the function in line 39...
o.O

DeanMSands3 69 Junior Poster

This smells suspiciously like a homework assignment. May we ask what have you done on this project so far yourself?

rubberman commented: :-) +12
DeanMSands3 69 Junior Poster

Just to make sure, you're using this code on this microcontroller, right?
http://www.atmel.com/devices/atmega8535.aspx

Somehow, I doubt that's going to work.
What kind of screen are you using?
Line LCD like this: http://www.digikey.com/product-detail/en/VI-322-DP-RC-S/153-1005-ND/10188
(which would make sense for an LCD clock)

OR

Text LCD like this:
http://www.digikey.com/product-detail/en/NHD-0216PZ-FL-YBW-PC/NHD-0216PZ-FL-YBW-PC-ND/2165970
(which would make sense for the code you're using)

DeanMSands3 69 Junior Poster

These aren't threads; they are processes (because you're using fork). Threads (also called light-weight processes) share the same memory space. Processes do not (until you tell them to).
Now, take a step back and ask yourself: Do I want threads or processes?
If you want threads, use the pthreads library. You will need to yank out the fork command and thread out onto a function then join back.
Have a look at the yolinux article: http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html

If you want processes, that's a different story. Have a look at shared memory and IPC. Here's a good place to start:
http://www.advancedlinuxprogramming.com/alp-folder/
Have a look at chapter 3 to get an idea of what's going on, then jump to chapter 5.

Also here: http://www.cs.cf.ac.uk/Dave/C/node27.html

DeanMSands3 69 Junior Poster

First setup an array. 20x20 is a good size, but you can go bigger.
Create a set of snake object. Give the snakes locations on the array.
Give the snakes each initial directions. It might help if they were all set on a different side of a wall, and have them move inward away from the wall.

In your main loop
Check for user input.
Adjust player snake's direction.
Process a simple decision making function for the computer snakes:
Something in my way? Check which way is clear, and move in that direction.
Going to crash anyway? OK, snake dies.
Player snake dead? Game over.
Advance each living snake one space.
Clear the screen.
Draw the grid on the screen.
Put in small pause to make the game play-able. You'll be dead in milliseconds otherwise.
Loop.

DeanMSands3 69 Junior Poster

Check out Cave Story. Then MineCraft. Both started out as one-man projects.

DeanMSands3 69 Junior Poster

Just a suggestion: http://unity3d.com/unity
It natively imports Maya.

DeanMSands3 69 Junior Poster

I worked it out with him over chat. Turns out it's a recursive #include between Transducer.h and Phonebook.h.
It's always the simplest things that drive you absolutely batty.

DeanMSands3 69 Junior Poster

I'm assuming that Text1-3 are text boxes.
I'd grab their "text" properties, then cast them to integers.
In programmer-ese, that's

Picture1.BackColor RGB(cint(Text1.Text),cint(Text2.Text),cint(Text3.Text))

OK, now correct me if I'm wrong (It's been forever since VB6 for me), but doesn't this need an equal sign between Picture1.BackColor and RGB(...) ?

Picture1.BackColor=RGB(cint(Text1.Text),cint(Text2.Text),cint(Text3.Text))

Also, I did some digging and it looks like you also need your Picture1.AutoRedraw set to true.

Hope that helps.

alina.nazchowdhury commented: thanks a lot, i knew something's missing, i have this book but sometimes the code is not done properly +0
DeanMSands3 69 Junior Poster

Name says it all. Is it still relevant? I guess wxPython sort of counts. What do you think Daniweb? Now, I don't want to start a flame war -said every troll ever.

DeanMSands3 69 Junior Poster

Ever since I took a serious look at game-making I've been intrigued by the idea of making my own scripting engine.
(I think two college courses of MIPS may have helped.)
I've had the wacky idea of writing a compiler that takes script code and compiles it down to byte code (ala MIPS).
Has anyone else tried doing their own script engine and how did it go? Any advice?

DeanMSands3 69 Junior Poster

OK, a few questions. Looking at the code as you posted it, I'm seeing some strange things.
First, Line 20: int x = inputFile.nextInt();
Why? You're sacrificing your first integer to the yawning Void of nothingness.

Then, Lines 23, 32, 42, 49: you have for(int i = 1; i < array.length; i++ )
Why? Again, sucks to be the first Int. In your Insertion Sort, I see you do the same thing, but there seems to be a good reason as j starts out as 1 less than i. Did you copy/paste and forget to change it back?

Also, GetCount does nothing. If anything, it should either change a static variable (less professional), or change its return type to int and return count (better).

And ShowCount which looks like it picks up where GetCount got abandoned isn't used, and frankly doesn't need to be, if you print out what you get back from using GetCount.