Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

As I said, you are passing a NULL pointer for pWalker. Fix that and it might work the way you want it to.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you do have to allocate memory, the problem is that you tossed it into the bit bucket by setting it to NULL in the else statement. You should not have commented out the two lines that set the next and previous variables to NULL -- that was correct.

Display_words() -- you do have to test pWalker for NUL because I see where a NULL pointer is being passed to that function (Display_Results()). Just a simple test will do it.

void Display_Words (word *pWalker, int &count)
{
    word *pCurrent;
    if(pWalker != NULL)
    {
        pCurrent = pWalker;
    
        while (pCurrent != letter[count])
        { 
            cout << pCurrent->newWord << " ";
            pCurrent = pCurrent->back;
        }

    }     

}

After making the above corrections I get this output, using the file that you posted

Results for file ..\TextFile1.txt: 6 total words processed.

2 word(s) beginning with 'G':
1 word(s) beginning with 'M':
1 word(s) beginning with 'S':
1 word(s) beginning with 'T':
1 word(s) beginning with 'W':


Press any key to continue . . .

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'm starting to step through you program now. So far it is full of memory leaks. First place I see is in the function Initialize_Linked_Lists(). First you allocate a word object then turn around and set the pointer to NULL and return a NULL pointer. Huge mistake.

Correct_Word(). When you erase a letter out of the word you have to adjust variable len in the loop because you changed the length of the string. Also reset count to -1 so that it starts that loop all over again.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I get a compile error with VC++ 2008 Express because you didn't include <algorithm> to define transform.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

word * pCurrent = pWalker; -- just don't use the new operator like you did on line 516.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you can start by deleting line 516 because it is nothing more than a huge memory leak.

When walking backwards you can't check for pCurrent == NULL because what you want to check for is while pCurrent != the head of the linked list, and the head is never NULL unless its an empty list. I assume pWalker is the point at which you want to start walking backwards, but what is the head of the linked list? If it isn't a gobal variable then you will have to pass it to the display function.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Another thing, where is the namespace std?

It wasn't used with that old version of iostream.h

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> but if you gave me the answer you would be credited a smarter person today
Answer: google for ways to do it. A lot easier and faster that way.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Unfortunately, this system ignores spaces, rendering it useless if a user were to type something like "go east". However, typing "go_east" works.

What I mean is that cin >> szword only accepts keystrokes up to the first space or the '\n' character. If you want everything up to the '\n' character then you have to use getline(), like this: getline(cin, szword); , assiming szword is std::string. If szword is a character array, then use this: cin.getline(szword, sizeof(szword)); And you don't need either cstdio or cstdlib because you are writing a c++ program, not a c program.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Maybe this will help

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It could also mean you have been listening too much to your new baby's baby talk. Maybe you need to hire a babysitter and get out for awhile.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That's called "old age creeping up on you" :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>is this valid
Probably not. Did you run that to see what it does? You probably need something like this: pwd=$dir + '/' + $date + '/' I assume you are doing *nix shell programming, hence the forward slashes.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

JRM: sorry but the loop you posted won't work either. I'll leave it up to you to figure out why

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> while(gallons != 0)
That while statement won't work because you never change the value of gallons, that makes it an infinite loop.

>> just don't know how to get the sum of all the tanks used
just sum them up as you enter them

int total = 0;
int gallons = 0;
do {
    cout << "Enter gallons\n";
    cin >> gallons
    cin.ignore(); // flush keyboard of the '\n' key
    total += gallons;
}while( gallons > 0);

When you fill your car with gas you have to record both the number of gallons and the distance traveled for the previous tank of gas. I would start out by filling the gas tank and setting the trip odometer to 0. The next time I get gas I would record the number of gallons purchased and the distance indiated on the trip odometer. Divide the two and I get the gallons/miles or galles/kilo or whatever measurement you want to use. Or you could just keep track of all the gallons then when the trip is finished do the division with the sum.

Now to do the same in the program, you didn't post the exact program requirements -- what you posted in ambiguous. Can you enter just two amounts -- total gallons and total distance ? Or do you have to enter gallons and distance for each tank of gas ?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Needs me for today
And when did you get that assignment? Your lack of ability to manage your time is not our problem.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you are missing the libraries that contain those functions. Get the libs from wherever you got those header files.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

think about how would you calculate the average galles per k with pencil & paper. Given the distance and gallons its just simply average = distance/gallons If you want the average over several tanks of gas then sum up all the gas you bought then do the division. This is just 5th grade (or earlier) math.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You might try Dev-C++ because it uses *nix port of g++ compiler. Get it free at www.bloodshet.net

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>what can i do?
If you are trying to port some program to MS-Windows you will have to rewrite parts or all of it. First determine what the function(s) is supposed to do then use win32 api functions or standard C functions to do it. MS-Windows does not support POSIX.

For example: ftruncate truncates a file to a specified length. The equivalent win32 api function is move the file pointer to the desired location then call SetEndOfFile() to truncate it.

The only header file you need for most win32 api functions is windows.h. If the function you need isn't in windows.h (such as the compiler complains that it can't find a function) then you have to look up that function in MSDN as www.microsoft.com and it will tell you what header files and libraries are needed.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

lets say you have two integers, n1 and n2

open file for input
read first integer into n1
start of loop to read until end-of-file
   read integer into n2
   subtract n2 - n1 and save result in a second file
   move value of n2 into n1
end of loop
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>The output will be in milliseconds.
But don't be supprised when the result is 0, which means the code runs so fast that it isn't measurable. In that case you may have to run the code several (hundreds or thousands) times between timings, probably in a loop.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you need to use a loop and divide the number by 10 until the result is 0.

you can delete lines 10 thru 19 because they are not relevent to the program requirements. The answer to the program has nothing to do with a space.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Since this is c++ you can use std::string's find() method to locate the colon then substr() method to extract everything after it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That compiler does not have unistd.h -- that is a *nix header file. There is no substitute for Windows.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Chariots of the Gods is a very interesting book that tries to explain many things on Earth were actually created by spacement who visited here. It was the inspiration for several popular sci-fi tv series and movies.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I tried putting in the arguements and it says that they are not recognized??
Since I can't see your monitor you will have to post the code you write. My eyesight isn't that good you know. :)

>>error C2660: 'showArray' : function does not take 0 arguments
Of course ShowArray takes two arguments -- did you really think you can just pluck something anywhere you want and it will work? Try reading the program where you see it called in other places and do the same thing in the sort function. And notice that the sort function changed the name of values to array, so you have to change it in the ShowArray() function call too.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you have to add ShowArray() at the bottom of the do loop in the sort function.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I am going to take that as a personal feeling of yours and not as a fact obtained based in a lifetime of worthless research.

Nope, not a lifetime of worthless research but maybe at most five minutes of it. Just think about all the past us presidents and name just one that wasn't a lier or cheater. They are all a bunch of crooks, but they can't help it because they were probably born that way.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

On the otherhand there are times when perfection is required. I don't want to jump out of an airplain with a parachute that was folded just "good enough" (I wouldn't jump out of a perfectly good airplain anyway, but you get my drift).

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Welcome back. Here is your last post.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>could this be the problem?
probably not, afterall many win32 api functions are in static libraries and they don't have that problem.

Can you compiler that library for debug so that you can see what is causing the exception ?

>>i catch the exception in the constructor, free all dynamic allocated variables and then rethrow the exception
Is the exception handler attempting to delete (or free) pointers that have not yet been allocated ? Are all pointers initialized to 0 during program startup so that the exception handler can test to see if they need to be deallocated ?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

hi!!! constructor has nothing to do with the array so dont be

Of course it does! The course constructure of each array element will be called when the student class is instantiated.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

yes, you need to code a default constructor for course so that the class variables get initialized. If you don't code it the default constructor won't do it either.

class course                                    
{
private :
   int a;
   float b;

public :
  course(int aa, int bb);
  course() {a = 0; b = 0.0F; } // <<<<< add this to your class

};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why do you need a whole tutorial just to declare an object with the extern keyboard? Its pretty trivel to code. Just put this near the top of the *.cpp file. extern int something;

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes, you can do that. The problem is that you are doing double the work that is necessary, and its very easy to make mistakes in the extern statements between the different files. If you only have one or two variables/functions you want to declare extern then by all means just put the statement at the top of the *.cpp files that need them.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Does that mean you have to be a real beast to run for president?

Yes. Politicians lie and cheat their way into office.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

A macro is something that is expanded by the compiler's preprocessor. A constant is like a normal variable but whose value can not be changed, nor is a constant affected by the preprocessor.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

did the program catch the execption that is thrown by the constructor? That's probably what cause that error

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Haha. Of course, getting a Ph.D. won't necessarily get you the knowledge you need to make a compiler unless you do it once. And of course, you don't need a Ph.D. to get the knowledge either. Heck, a Ph.D. in chemistry wouldn't give you compiler-making skills :)

Yes -- he wasn't very specific about what he wanted. Getting a Ph.D. in computer science should provide adequate background to making a compiler. Afterall, Dr. Stroustrup did it :)

But to be a little more helpful, he might want to use these tools.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That is a C program, not C++. What parts don't you understand ?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you are uisng win32 api timer event function SetTimer() to start the timer then you can use KillTimer() to stop it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The constructor for student doesn't have to do anything at all with the array of courses because class course will take care of it. All student has to do is initialize its own variable g.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Why we get the core file
Because you made errors in the program.

>>how can we debug it in unix
tutorial

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

IMO the best was is to take college classes. If you can't do that (maybe because you aren't in college) then the next best thing is to buy a book and start reading from page 1. Here is a thread about the best recommended books.

Then of course you need to get a c++ compiler. Microsoft VC++ 2008 Express is free and easily downloaded from here. There are also several other free compilers that may be easier to learn how to use, such as Dev-C++ and CodeBlocks

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>is it now better???
Don't ask me but ask yourself. Does it work right? No, then its not better.

lines 11 and 12: you need to initialize the arrays to 0. Easy to do like this: int value[5] = {0}; Now intialize the other one just like that.

line 23: should be testing value and array if(array[j]==value[i]) delete lines 27 and 29 because they serve no useful purpose.

There are at least a couple other problems.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Step #1: Get a Ph.D. from a good university. After you get that you will have all the knowledge you need to design and write your own compiler.

Don't believe me? well, if you don't then read this thread.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The MySQL web site has a set of C++ classes that you can use. See MySQL++. There are also several ODBC c++ classes, some free and some not. Just look at these links