DeanMSands3 69 Junior Poster

Assuming a square NxNmatrix where N is an odd number, it looks like:
Find the center (x,y) where x and y equal N/2 rounded down. Or N>>1;
Go Up One.
Go Right One.
Go Down Two.
Go Left Two.
Go Up Three.
Go Right Three.
...
Happy coding.

DeanMSands3 69 Junior Poster

My original posting would have included mildly insulting remarks about the needlessness of trying to do Layer 1("You're doing it wrong" and "These are not the droids you're looking for"). I even thought about including a link to some microcontroller websites (and ContikiOS now that I think about it) so he could get down to the bare metal. But then I realized, no, none of that would have been helpful.

I posted what I did, and stand by it.

DeanMSands3 69 Junior Poster

Have a look at WinPCap and the related project WireShark.
Good luck and happy coding.

DeanMSands3 69 Junior Poster

The best way to learn C/C++ is to just sit down with it for a weekend and play with it. Use it to draw a tree. Figure out the price of dinner for two plus tax. Write a number guessing game.
Then when you're feeling ready, write a small program organizes your CD collection by name and stores it in a file. Write a small game like Tetris. Do a podcast ripper.
Pick a project and go for it.

As far as the compiler to use, let me make some suggestions:
Labdabeta is right. Code::Blocks is a good one. I'd recommend starting with it rather than Eclipse or Netbeans because they don't have the compiler pre-bundled in. Once you've gotten a hang of how the compiler works and how linking is done, THEN move to Eclipse or Netbeans and find a separate compiler i.e. GCC or LLVM/Clang.

DeanMSands3 69 Junior Poster

I would say that's platform and compiler dependant. What are you using?

DeanMSands3 69 Junior Poster

This question has already been answered the last time you posted this. The BGI error is telling you that your program compiled by Borland Turbo C++ can't find the right file for its graphics library.
And yes, we only need to see the article title to know it's Turbo C++. Though, the #include's would have been a second clue.
What you need to do is set your path to include the directory you have your BGI files in.
Or copy the right BGI file into the same directory as your executable. (But you'd have to do that every time.)
Actually, what you need to do is drop Turbo C++ and move on to bigger and better things. Things you can get for free. Legally.
If you're interested in porting this program to something usable, let us know in the forums or send me a PM.

rahulraj9 commented: help him +0
DeanMSands3 69 Junior Poster

Learn regular expressions.
Boost::Regex

DeanMSands3 69 Junior Poster

Ancient Dragon is right, but let me offer a few tips on how to hold the hammer.

  1. Make sure Eclipse and the C Development Tools are installed.
  2. Make sure you have a C++ compiler that will work with them. On Windows, I recommend MinGW w/MSYS.
  3. Make sure Eclipse can find your compiler.
  4. Make sure you have the libraries for what you're trying to do.
  5. Make sure they get linked in when you compile.
    Project->Properties->C/C++ Build->Settings->(Your Compiler) Linker->Libraries

And you're good to go.

DeanMSands3 69 Junior Poster

You're definitely on the right track.

void move(int array[], int n, int m)
{
    int i;

    if(m == 0) {
        return;
    }else {
        move(array, n, m-1);
        if(i+m>n) {
            array[i+m] = array[i+m-n];
        }
        array[m-1] = array[m];

    }

}

Now tell us what your i variable is supposed to do? You're reading from it (the i+m>n counts as a read) before you give it a value. Which is a no-no. Also, you're not changing it in any way. The key to this is fixing the i. And you probably need a temporary value somewhere to hold what you're over-writing.

Lastly, I screwed up on my earlier attempt to explain a recursive function. The web browser ate my post, and I had to redo it. Well, the second time around, I was annoyed and not nearly as cautious.

unsigned long factorial(unsigned long n){
    if(n>1)
        return factorial(n-1);
    else
        return 1;
}

Should be:

unsigned long factorial(unsigned long n){
    if(n>1)
        return n*factorial(n-1); //notice the "n*"
    else
        return 1;
}

I had to flag my own post as bad. :(

DeanMSands3 69 Junior Poster

OK, let me rephrase that. Your Game class SHOULD be in a header file. And both TicTacToe.h and War.h SHOULD #include it.

DeanMSands3 69 Junior Poster

Where are you defining your Game class and, if it's in a header file, do both TicTacToe.h and War.h #include it?

DeanMSands3 69 Junior Poster

See this line?
class War: public Game

You're declaring War to be a derived class of Game.

See this line?
class TicTacToe

You're declaring TicTacToe to be a class of its own with no base class.

DeanMSands3 69 Junior Poster

if(arr1[j][0] == arr2[k][0])

This is not how to do string comparisons in C.

http://www.cplusplus.com/reference/clibrary/cstring/strcmp/
When the two strings are the same, strcmp will return 0.

There may be other bugs, but this is the one that stood out to me.

DeanMSands3 69 Junior Poster

http://www.opengl.org/sdk/docs/man/xhtml/glGenTextures.xml

There is no guarantee that the names form a contiguous set of integers; however, it is guaranteed that none of the returned names was in use immediately before the call to glGenTextures.

DeanMSands3 69 Junior Poster

A recursive function calls itself with slightly modified parameters from those it was called with.
Here's an example of a recursive function.

unsigned long factorial(unsigned long n){
    if(n>1)
        return factorial(n-1);
    else
        return 1;
}
DeanMSands3 69 Junior Poster
Begginnerdev commented: LOL'd at "Vote for Pedro." +0
DeanMSands3 69 Junior Poster

I dont know semaphores and threads

Then start learning. Read up on them then write a small program that illustrates how they work.

@Ancient Dragon: And an upvote for you, sir.
@SAM2012: Here's the link again. http://msdn.microsoft.com/en-us/library/windows/desktop/ms686946

DeanMSands3 69 Junior Poster

OK. You set up a direction variable that your snake bases its movement off of.
Let's call it direction. (Put this early in the beginning, before the loop).

enum direction { UP, DOWN, RIGHT, LEFT};
direction=UP; //Start snake facing up.

Now, direction does not change UNLESS the user presses a key.

    if(kbhit()){
        input=getch();
        // go in up direction when press "W" Or 'up'
        if(input == (char) 119 || input == (char) 87 || input == 72)
        {
            direction=UP;
        }

        // go in down direction when press "S" Or 'down'
        if(input == (char) 115 || input == (char) 83 || input == 80)
        {
            direction=DOWN;
        }
        // go in right direction when press "D" Or 'right'
        if(input == (char) 100 || input == (char) 68 || input == 77)
        {
            direction=RIGHT;
        }
        // go in left direction when press "A" Or 'left'
        if(input == (char) 65 || input == (char) 97 || input == 75)
        {
            direction=LEFT;
        }
    }

And in every loop, we update the snake's location, based on direction REGARDLESS of whether a key was pressed.

        switch(direction){
            case UP:
                snake[0].y--;
                break;
            case DOWN:
                snake[0].y++;
                break;
            case RIGHT:
                snake[0].x++;
                break;
            case LEFT:
                snake[0].x--;
                break;
            default: //In the event that something weird happens.
                direction=UP;
                snake[0].y--;
                break;
        }
DeanMSands3 69 Junior Poster

Yeah, I was worried that answer would be completely useless. Let me ask this: How are you getting your messages and what are you using them for?

DeanMSands3 69 Junior Poster

OK, claywin, we really can't help you the way you want us to. Not with the information we have. So here's what we're going to do:

    SDL_Rect rcSrc, rcPlayer;
    std::cout<<"Player object created!\n";

    SDL_Init(SDL_INIT_VIDEO);
    std::cout<<"Video initialized!\n";
    SDL_WM_SetCaption("Untitled", "Untitled");
    std::cout<<"Caption set!\n";
    screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
    std::cout<<"Video Mode set!\n";
    temp  = SDL_LoadBMP("grass.bmp");
    std::cout<<"Grass texture loaded!\n";
    grass = SDL_DisplayFormat(temp);
    std::cout<<"Grass object created!\n";
    SDL_FreeSurface(temp);
    std::cout<<"Grass texture freed!\n";
    SDL_EnableKeyRepeat(25, 25);
    std::cout<<"Key repeat enabled!\n";
    gameover = 0;

(Make sure to #include<iostream.h>)
Check points have been an invaluable service in my debugging.

DeanMSands3 69 Junior Poster

The way to do this is to run a thread that handles updating the observers. The thread itself waits for a semaphore linked to the queue. Every time, you enqueue a new message, you increment (release) the semaphore.

This link may be helpful:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms686946

As a bonus, if you're going to run a thread specific to the queue, create a static "runThread" method in the class that takes the object pointer (this) as it's parameter. This will save you a few hours of headaches.

DeanMSands3 69 Junior Poster

In regards to your redundant class X;, remove them from the beginning of each header not counting A.h. You're including the header files so you don't need an additional class statement.

In regards to the run-time error: yes, exactly. A pointer is not the object it points to. It's like having a mailbox without a house.

#include "D.h"
#include <string>
class D;
int main(){
    D* d=new D(); //Add Me!
    d->add();
    d->sh();
//  d->show();
    return (0);
}

EDIT: Credit goes to gusano79 whose post I've already up-voted.

DeanMSands3 69 Junior Poster

Well, there are a couple of things you can do. You can poll the queue repeatedly, checking to see if it's not empty.

void someFunction(){
    while(1){//Loop forever.
        if(myQueue.Empty()==false){
            doSomethingAmazing(myQueue.popFront());
        }
    }
}

This is kind of wasteful.
Or you can put in an observer-relationship. You create an observer object list in your queue and make assignments of who's watching it. Once a message is received, you update all the observers with the message.

void queue::Enqueue(message^ key)
{
    if (head == nullptr)
    {
        head = tail = new ListNode(key);
    }
    else
    {
        tail->next = new ListNode(key);
        tail = tail->next;
    }
    //Loop through and update all observer objects
    for(int i=0; i<observers->Length; i++)   
        observers[i]->update(key);
}

However, this is also not super useful as you defeat the purpose of having a queue by updating everything at once AND you risk missing messages while updating.

So essentially, I've given you two bad ideas, but I'm leading up to the good idea.
Which I'm going to tell you about after lunch. (Hint: It involves threading.)

DeanMSands3 69 Junior Poster

OK, your paradigm needs a little work.
Three things I see.

  1. What you're doing is you're getch()-ing every time you loop. Getch() is a show-stopper. The program won't continue until it has that key press. This won't work for an action game. You need to preface the getch with an if(kbhit()).

  2. Your snake is basing its movement on user input. What it should be doing is basing its DIRECTION on user input. If its direction is up, it will keep going up. If its direction is left, it will keep going left. And on. And on. Each loop should progress the snake further in that direction. Only when a key is pressed, does the direction change.

  3. Slow it down. This is where it gets tricky. As soon as you implement the preceding two steps, you will find yourself starting the game and having it end before you've finished letting go of ENTER. It looks like you're using Turbo C++. I'd recommend dropping that and getting something more modern (and perfectly legally free). For Turbo C++. you'll need to use the delay(unsigned int milliseconds) function. I'd recommend a value of maybe 250 - 400. If you've upgraded to a modern compiler, you can use the windows sleep(unsigned int milliseconds) function. Turbo C++ has a sleep function, but it counts in whole seconds.

PeTo. commented: sorry but I dont understand ur 2nd point what do you mean by my snake is basing its movement on user input. What it should be doing is basing its DIRECTION on user input ? can u show me an example , also my snake is leaving some points behind I tried to +0
DeanMSands3 69 Junior Poster

face palm
Good cal, nezachem.

DeanMSands3 69 Junior Poster

@Lerner: Actually, suhasgh's right. The delete kills the object instance, but the erase deletes the lingering pointer kept in memory. However, I'm curious about the erase statement and if it's killing the right entry each time.
As far as the for loop that cleans up, I'd yank the erase. Then after the for loop, I'd place a clear statement afterward. Clear will erase the entire list.

DeanMSands3 69 Junior Poster

I need GMPXX on MinGW. This is driving me nuts.
EDIT: I should mention I've tried using the precompiled MinGW GMP and GMPXX libraries via the mingw-get. And they fail. I removed them.
I compiled GMP in MSYS with the following line.

./configure --enable-cxx --prefix="/mingw" && make && make install && make check

And it comes out perfectly.

Here's my code:

#include <gmpxx.h>
#include <iostream>

mpz_class pascal[101][101];

int main(){
    unsigned int i,j;


    for(i=0;i<102;i++){
        pascal[i][0]=1;
    }

    for(i=1;i<102;i++){
        for(j=1;j<102;j++){
            pascal[i][j]=pascal[i-1][j-1]+pascal[i-1][j];
        }
    }

    std::cout<<pascal[100][50];
    return 0;
}

Then I try:

$ g++ -v -lgmpxx -lgmp -o Pascal.exe Pascal.cpp
Using built-in specs.
COLLECT_GCC=C:\MinGW\bin\g++.exe
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.6.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.6.2 (GCC)
COLLECT_GCC_OPTIONS='-v' '-o' 'Pascal.exe' '-shared-libgcc' '-mtune=i386' '-march=i386'
 c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/cc1plus.exe -quiet -v -iprefix c:\mingw\bin\../lib/gcc/mingw32/4.6.2/ Pascal.cpp -quiet -dumpbase Pascal.cpp -mtune=i386 -march=i386 -auxbase Pascal -version -o C:\DOCUME~1\DMS40\LOCALS~1\Temp\ccHjg98a.s
GNU C++ (GCC) version 4.6.2 (mingw32)
        compiled by GNU C version 4.6.2, GMP version 5.0.1, MPFR version 2.4.1, MPC version 0.8.1
warning: GMP header version 5.0.1 differs from library version 5.0.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.2/include/c++"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.2/include/c++/mingw32"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.2/include/c++/backward"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.2/include"
ignoring duplicate directory "/mingw/lib/gcc/mingw32/4.6.2/../../../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.2/include-fixed"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.2/../../../../mingw32/include"
ignoring duplicate directory "/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
 c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++
 c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/mingw32
 c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/backward
 c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include
 c:\mingw\bin\../lib/gcc/mingw32/4.6.2/../../../../include
 c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include-fixed
 c:\mingw\bin\../lib/gcc/mingw32/4.6.2/../../../../mingw32/include
End of search list.
GNU C++ (GCC) version 4.6.2 …
DeanMSands3 69 Junior Poster

Alpha channel perhaps?

DeanMSands3 69 Junior Poster

Props to nezachem. I was going to suggest the same thing. Did a little research on some broadcast tuts and learned that APPARENTLY broadcast is dead, long live multicast. Huh.

http://lmgtfy.com/?q=winsock+multicast+example

Also, don't forget that with any WinSock program you write, you'll need to link in the appropriate library for your compiler. Otherwise, you'll get obscure errors about this or that reference being missing.

DeanMSands3 69 Junior Poster

EDIT: Labdabeta beat me to it! I spent so much time on this one! Darn the luck!

I'd suggest a recursive function with a backtracking mechanism like a stack or a double-ended queue.

deque<yourClass> *myRecursiveFunction(vector< vector< yourClass > > *dataSet){
    deque<yourClass> *dataSelected=new deque<yourClass>();
    if(myRecursiveInnerFunction(currentDataSet, 0, dataSelected))
        return dataSelected;
    else
        return NULL;
}

bool myRecursiveInnerFunction(vector< vector< yourClass > > *dataSet, int indexInDataSet, deque<yourClass> *dataSelected){
    //Have we reached the end yet?
    if((*dataSet)[indexInDataSet].size()>indexInDataSet){ 
        //Nope! Still going. 
        //Let's loop through 
        for(int i=0;i<(*dataSet)[indexInDataSet].size();i++){
            //Push next data piece onto the stack.
            dataSelected->pushBack((*dataSet)[indexInDataSet][i]);
            if(testValidHypothesis(dataSelected)){
                //OK, this will work. So far so good.
                if(myRecursiveInnerFunction(dataSet, indexInDataSet+1, dataSelected)){
                    //Hey! It worked! Ride the returns up back to the top!
                    return true;
                }
            }

            //If we made it here, the data didn't work out. Oops.
            //We remove the last piece.
            dataSelected->pop_back();
            //And we loop again.

        }
        //Looked through all possibilities for this set. An earlier piece of data must be wrong.
        //Going back and trying again.
        return false;
    }
    else{
        //We've come to the end of the line. Everything checked out. We're done.
        return true;
    }
}
DeanMSands3 69 Junior Poster

OK, explain this bit.

slen = (unsigned) strlen(keyPtr);
      slen2 =(unsigned) strlen(keyPtr2);
      if( strlen(slen) == NULL && strlen(slen2) == NULL)
      {
        fprintf(stderr, "\n\tNo keys entered. You must enter 2 keys.\n");
        error = 1;
      }


      if(strlen(slen2) == NULL)
      {
        fprintf(stderr, "\n\tOnly 1 key entered. You must enter 2 keys.\n");
        error = 1;
      }

You're getting a strlen from a number that's already the string length of your keys? I'm assuming you started on one approach then changed your mind and started with a new one but forgot to clean out the old code. It's cool. We all do that now and then.

      slen = (unsigned) strlen(keyPtr);
      slen2 =(unsigned) strlen(keyPtr2);
      if((slen == 0) && (slen2 == 0))
      {
        fprintf(stderr, "\n\tNo keys entered. You must enter 2 keys.\n");
        error = 1;
      }


      if(slen2 == 0)
      {
        fprintf(stderr, "\n\tOnly 1 key entered. You must enter 2 keys.\n");
        error = 1;
      }

And why are you using NULL instead of 0? NULL is 0 cast as a void pointer. I mean you can, and it'll probably work, but I wouldn't.

I'm going to assume this is not all and there is another lingering question somewhere.

DeanMSands3 69 Junior Poster

I'm assuming you mean a visible stamp on the image. Yes, you should compress AFTER watermarking.

DeanMSands3 69 Junior Poster

Read this:
http://en.wikipedia.org/wiki/Jpeg#Discrete_cosine_transform
I'll see if I can find some source code.

DeanMSands3 69 Junior Poster

Two thoughts on this one.

A. Use memmove (which allows source/destination overlap) to relocate the values like so:

memmove(&data[51],&data[50],49*sizeof(int);
data[50]=42;

B. Use a for loop that works backwards.

for(int i=99;i>50;i--){data[i]=data[i-1];}
data[50]=42;

Frankly, the second should have been a little obvious.

DeanMSands3 69 Junior Poster

cleaner->vacuum
(I wanted to say 'maid', but worried that might be sexist. Let's see where vacuum takes us.)

DeanMSands3 69 Junior Poster

@lucianandrew: Sorry for the long-delayed response. Yeah, he is an awesome professor, though I haven't had him in any classes for some time now.

@Forbidden Yes No game: The trickiness of the question is in direct proportion to the airspeed of an unladen swallow.
Is it an African swallow in stead of a European swallow?

DeanMSands3 69 Junior Poster

Now your new code:

/*
 ============================================================================
 Name        : Pointers.c
 Author      : dan1992
 Editor      : Dean M. Sands, III
 Version     : 0.2
 Copyright   : I will steal your lawn gnomes. And then the flamingos burn.
 Description : Algebraic Complement in C with Pointers
 ============================================================================
 */

#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <malloc.h>


int **allocateMatrix(unsigned int rows, unsigned int columns){
        int i, **matrix;
        //Malloc only allocates X number of bytes. It doesn't care that you want X number of INT pointers.
        //An INT pointer is a lot bigger than a byte.
        //So we have to specify:
        matrix=(int**)malloc(rows*sizeof(int*));        //Allocate pointers to rows
        printf("Matrix allocated!\n");
        if(matrix==NULL)
                return NULL;
        for(i=0;i<rows;i++){
                matrix[i]=(int*)malloc(columns*sizeof(int));    //Allocate each row
                printf("Row allocated!\n");
                if(matrix[i]==NULL){
                        return NULL;
                }
        }
        return matrix;
}

void deallocateMatrix(int **matrix, unsigned int rows){
        int i;
        for(i=0;i<rows;i++){
                free(matrix[i]);
        }
        free(matrix);
}



int main(){

        //int a[4][4],b4[3][3],b1[3][3],b2[3][3],b3[3][3],n,c1,c2,c3,c4,i,j;
        unsigned int n;
        int **a,**b4,**b1,**b2,**b3,c1,c2,c3,c4,i,j;
        n=4;
        //print("What size square matrix do you want? ");
        //scanf("%d", &n);
        a=allocateMatrix(n,n);
        if(a==NULL){
                printf("Could not allocate a.\n");
                return 0;
        }

        b1=allocateMatrix(n-1,n-1);
        if(b1==NULL){
                printf("Could not allocate b1.\n");
                return 0;
        }

        b2=allocateMatrix(n-1,n-1);
        if(b2==NULL){
                printf("Could not allocate b2.\n");
                return 0;
        }

        b3=allocateMatrix(n-1,n-1);
        if(b3==NULL){
                printf("Could not allocate b3.\n");
                return 0;
        }

        b4=allocateMatrix(n-1,n-1);
        if(b4==NULL){
                printf("Could not allocate b4.\n");
                return 0;
        }


        //printf("\nIntroduceti elementele Matricei cu 4 linii si 4 coloane: \n");
        printf("\nEnter the matrix elements with 4 rows and 4 columns: \n");

        for (i=0; i<n; i++){
                for (j=0; j<n; j++){
                        printf("a[%d][%d]=",i+1,j+1);
                        scanf("%d",&a[i][j]);
                }
        }

        printf("\n Matrix: \n");
        for (i=0; i<n; i++){
                for (j=0; j<n; j++){
                        printf("%2d ",a[i][j]);
                }
                printf("\n");
        }


        for (i=0; i<n-1; …
DeanMSands3 69 Junior Poster

First, here's a tutorial on pointers:

/*
 ============================================================================
 Name        : PointersExplained1.c
 Author      : Dean M. Sands, III
 Version     : 0.1a
 Copyright   : I will set fire to the flamingos in your front yard.
 Description : A code explanation of pointers
 ============================================================================
 */

#include <malloc.h>
#include <stdio.h>
#include <conio.h>


int *i; //Define i as a pointer. Its present value is meaningless.
int j=0;  //Define j as an integer with a value of 0.

void pointerAsAReference(){
    printf("j is an integer that contains: %d\n", j);
    printf("i is an int pointer that contains: %d\n", i);
    printf("And no one cares about i right now since we haven't given it a useful value.\n");
    printf("That's right, i. No one likes you.\n");

    i=&j; //Assign the location of j into i;
    printf("We plugged j's location into i.\n");
    printf("j still contains: %d\n", j);
    printf("i now contains: %d\n", i);
    printf("OK, i...\nI apologize for the hurtful things I said earlier. You're truly useful now.\n");
    printf("...\n");
    printf("No, you can't borrow money.\n");

    *i=4; //Assign the number 4 to the space pointed to by i. j now contains 4.
    printf("Hey look what we can do! We assigned a value to the space pointed to by i\n");
    printf("i still contains the address: %d\n", i);
    printf("j now contains: %d\n", j);
    printf("You're so special, i!\n");
}

void pointerAsSingleElementArray(){

    i[0]=10; //Pointers can be used as variables.
    printf("Ooh! This is neat. Let's use i as a single element array!\n");
    printf("j now contains: %d\n", j);

}

void pointersToAllocatedBuffers(){
    int x; //loop variable
    //Allocate a buffer the size of j integers and …
DeanMSands3 69 Junior Poster

There are three methods your employer will convey untruths. Lying, damned lying, and statistics. Badly commented code is also popular among programmers.

Wowbagger.

DeanMSands3 69 Junior Poster

Because you've had one too many.

If two wrongs don't make a right, but three rights make a left, how will adding ternary operators to my C code affect its readability?

DeanMSands3 69 Junior Poster
DeanMSands3 69 Junior Poster

I'm using the 620 WinLoader software that ties to an ancient Honeywell LM 620-25/35.

And I've gotten it to work in a one-to-one connection with an RS422 USB adapter. (After lots of rewiring cables.)

Now the tricky part. I've got a coworker who wants to remote into a single box and control 8 LMs (one at a time).

The 620 WinLoader software will only recognize COM1 or COM2.

I figured "No worries!" I'll just use hub4com from the com0com project and tie the COM lines (again, one at a time) to a virtual COM 1. Nope. hub4com won't do it the way Honeywell wants it to. Swell.

I can get an RS422 switch for $600. I'd rather not.

Some thoughts I've had is renaming the COM port via a program. It can be done in Control Panel, but my coworker is going to run into snafus doing that over and over.

I wanted to write a program to do this automatically. However, according to a Microsoft forum, I've found this is not something the average programmer really wants to deal with. facepalm Fabulous. (Note that I'm still considering it.)
I've also found this page by FTDI: http://www.ftdichip.com/Support/Utilities.htm . This might be user friendly enough. I'll ask him when he gets back in town.

Help me, DaniWeb-Kenobi! You're my only hope!

DeanMSands3 69 Junior Poster

Engine001 is suitable for what you want.
First, visualize what you want. You want to create a Role-Playing game.

Then start small. Make a game with a single room and a single character.
Write some backstory on that character. Why is he or she in the room? What does he or she hope to accomplish? Also, the room. What is the purpose of the room?
Then create another room. What is the purpose of that room?

Experiment. Can you open doors? Open chests? Turn on switches? And so on.

Create another character for your first character to meet and join with? What's this character's motivations for joining? What's the cause? Is it money, power, the building of a better world, or plain boredom?

What is the opposition to your quest? A secret band of assassins? Evil robots from outer space? A vast world government? Vegetarian chickens come to wreak havoc on the ignorant meat-eating masses?

See what you can do.
We expect great things.

DeanMSands3 69 Junior Poster

Your code is already to go really. Just make these changes:

  /* Read lines from input file */
  while(fscanf(finp, "%s", line) != EOF)
    {
      insert(head, line);
    }






void insert(struct tree_node *head, char *li)
{
  if(head == NULL)
    {
      head = (struct tree *)malloc(sizeof(struct tree_node));
      if(head == NULL)
    {
      printf("Node allocation failed.\n"); fflush(stdout);
      exit(1);
    }
      strcpy(head->line, li);
      head->left_child = NULL;
      head->right_child = NULL;
    }
  else
    {
      if(strcmp(head->line, li) < 0)
    {
      insert(head->right_child, li);
    }
      else
    {
       insert(head->left_child, li);
    }
    }
}

Happy coding!

DeanMSands3 69 Junior Poster

Shall I burst these bonds that hold me or yet remain, cowering in the safety of the darkness?
Determination.

codeorder commented: .don't do it man, it's not worth it.. xD +0
DeanMSands3 69 Junior Poster

I'm not entirely sure what you're trying to accomplish with the squeeze function.
I will tell you this:
Instead of

for(i=0; i<s1; i++) {

you probably want

for(i=0; i<strlen(s1); i++) {

strlen requires string.h, not to be confused by the C++ string header.

DeanMSands3 69 Junior Poster

The Compiler is expecting you to use a Class object with those functions unless you declare them as static.
In your header, put static in front of the declarations (i.e. right before the word void), but not in the implementation.

DeanMSands3 69 Junior Poster

Any modern compiler will work for you.

That said, I recommend starting out with Code::Blocks.
www.codeblocks.org/

While this isn't the biggest and the best, it's one of the easier methods.
For Graphics, you will want to use DirectX, OpenGL, Allegro, SDL or SFML.
The easiest is SDL.
http://wiki.codeblocks.org/index.php?title=Using_SDL_with_Code::Blocks

When you've got a handle on compiling and linking, I'd recommend upgrading to NetBeans then Eclipse. Both will require MinGW w/MSYS.
I still use NetBeans for most of my projects because it's comfortable. NetBeans just feels easier to use. However, Eclipse is where the money's at. It's super configurable and super extendable.
These are worth looking into.
http://plugins.netbeans.org
http://marketplace.eclipse.org/

And when you're ready to branch out, I recommend you look into the Allegro and SFML libraries.

http://sfmlcoder.wordpress.com/downloads/ - Compiled SFML2 by Xander
http://alleg.sourceforge.net/

DeanMSands3 69 Junior Poster

C# is a gateway language. You can port it to Java or to C++/CLI. And from C++/CLI to straight C++.

DeanMSands3 69 Junior Poster
If the input for the gender doesn't match 'F' and doesn't match 'M' complain and exit.
if(gender!='F'&&gender!='M'){
    cout<<"Invalid Gender."<<endl;
    return 0;
}

If the input for the activity doesn't match 'I' and doesn't match 'A' complain and exit.
if(level!='I'&&gender!='A'){
    cout<<"Invalid Activity Level."<<endl;
    return 0;
}