~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You remind me of the old times.

I put in fur.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

that her very

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Beginning of the new end, the dawn of destruction.

mattyd commented: Beginning of the new end, the dawn of destruction--matty +5
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Symphony of destruction - Megadeth

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

British chavs with a million, returning babies ate the cake while FEEDING a starving county.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

But the OP did this. Reread the code; there's nothing wrong with the way he/she implemented preprocessor directives.

....albeit, in a wrong way.

When you write guards like that to prevent recursive inclusion, you need to specify the Header file name in the preprocessor directives and not the class name. The OP has used the class name (Ship_State) instead of the header file name (w.h).

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

No, for both.

If you need a less complicated way, the only thing you can do is follow the code example and make one for your needs.

And since Registry is windows specific, you need to use W32 API to access the registry. There is no portable or easy way out, as far as my knowledge goes.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The way you are trying to incorporate the wrong concept of const variables in your program is causing all the problems.

If you declare a variable as const, you need to specify the const qualifier before the dataype, like this:

const int SIZE = 10 ; // you must specify the value

Since const variables can't be modified (alteast not using the same name) you need to specify an initial value for the variable the way I have done above. Also since initialization of non static members inside a class is not allowed in C++, so you have to make those variables static.

static const double dt=1.0  ;
   static const double gravity=0.5 ;
   static const double engine_strength = 1.0 ;
   static const double safe_velocity = -0.5 ;
   static const char burn_key = 'b';

You could also create a seperate header file with the constants and include it whenever you need to use the values.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Look into the functions RegOpenKeyEx, RegQueryValueEx and RegCloseKey. They are used for opening the registry, reading values from the registry and closing it. Refer the MSDN for more details.

An example snippet here.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You need to tell the compiler that the class you are using exists. You do this by something known as forward declarations.

// Enemy.h
#ifndef ENEMY_H
#define ENEMY_H
class Player ;  // forward declaration

class Enemy
{
    int c ;
    int d ;

    public:
        int get (Player a) ;  // now this works

} ;
#endif
// Player.h
#ifndef PLAYER_H
#define PLAYER_H

class Enemy ; // forward declaration

class Player
{
    int a ;
    int b ;

    public :
        int get (Enemy a) ;  // now this works
} ;
#endif
// Driver.cpp

#include "a.h"
#include "b.h"

int main()
{
    Enemy e ;
    Player p ;

    return 0;
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Not to forget that his scheme will work only for characters whose count is less than or equal to 9. Any higher and the algo is busted.

@OP Maybe you should try out [search]sprintf[/search] instead of adding plain ascii characters.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

all over the

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

No I wasn't asking, I was correcting. :cheesy:

;)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Well, doing that would be really simple. Posting the entire solution would be like wasting the efforts Narue and the others have put in solving the OP's problem.

I would leave the OP to figure out this one for himself.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

How does your version sort the words of same occurrence into alphabetical order though. I can't see it?

Oh, I guess I overlooked that requirement. Here is the fix:

static int wordOccurrenceSort(const void *p1, const void *p2)
{
   struct crap *sp1 = (struct crap *) p1;
   struct crap *sp2 = (struct crap *) p2;

    if (sp1->wordOccurrence == sp2->wordOccurrence)
        return strcmp (sp1->word, sp2->word) ;
    else
        return  (sp1->wordOccurrence - sp2->wordOccurrence) ;
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
static int wordOccurrenceSort(const void *p1, const void *p2)
{
   struct crap *sp1 = (struct crap *) p1;
   struct crap *sp2 = (struct crap *) p2;
   
   if (sp2->wordOccurrence > sp1->wordOccurrence )
   {
      return 1; //not sure what value to assign?
   }
   
   if (sp2->wordOccurrence < sp1->wordOccurrence )
   {
      return 0;//not sure what value to assign?
   }
   
   if ( sp2->wordOccurrence == sp1->wordOccurrence)
   {
      int order = strcmp(sp1->word,sp2->word);
      return order;
     //not sure what value to assign?
   }
}

You could simply have done something like this since this function is required to return how one element is placed wrt another and not any absolute value. Only the sign matters here (+ve, -ve, zero).

static int wordOccurrenceSort(const void *p1, const void *p2)
{
   struct crap *sp1 = (struct crap *) p1;
   struct crap *sp2 = (struct crap *) p2;
   
   return  (sp1->wordOccurrence - sp2->wordOccurrence) ;
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You get attend their concert.

I put in some grass.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

so can you explain how this variable declaration works when it get repeated.
y won't u get the error the redefinition of var x?

Think of this as declaring a variable in the naked block, whose scope and lifetime is limited to the block in which it is declared.

int g_myVariable = 100 ;   // global scope and lifetime

int main (void)
{
    int main_myVariable = 100 ;  // local to the function main

    for ( int i = 0; i < 10; ++i )    // scope of i is the entire loop block
    {
         int j = 0 ;    // j is destroyed after each iteration and a new 
                           // one is created at the start of every iteration
    }
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

all Daniweb members

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Broken Home - Papa Roach

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

heaven - demons

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

kind of trouble

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You get www.download.com

I put in a glass pane.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Toes count in our body should be two for us to pass out as normal humans.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

French SOLDIERS and a fleet of battleships followed commands while incarcerating a hostile daffodil.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You are getting an error because you are trying to print the "input stream" and not the "character array". In your use of fgets ( ) , "input" is the stream from which you are reading, line by line.

char buffer [BUFSIZ] = { '\0' } ;

while ( fgets (buffer, BUFSIZ, file_stream) != NULL )
{
    // process the line keeping in mind that it
    // has a newline at its end
   printf ("%s", buffer) ;
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hate to feel - Alice in Chains

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You get a unique breed of dog.

I put in karma.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

leak

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

can do better.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Brave berserkers and a FLEET of tanks followed soldiers while capturing a hostile country.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

rule the world.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I stand alone - Godsmack

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

skin -> shed

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Results of nuclear warfare are so very obvious. Extinction of human race...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

leet

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Being a honest person, I hand it back to you so that it isn't misused.

I put in a mongrel.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

s.o.s, Ancient Dragon; thank you for the advice.

You are welcome. Oh and btw, best of luck with your project...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Arrangement for parties has to be done well in advance.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Python -> Boa

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

YOu get some ninjas holding it.

I put in a light bulb.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

creep

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Only then can

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Falling away from me - Korn

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Come to think

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Brave cavaliers and a mass of TANKS followed soldiers while capturing a hostile country.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Brave cavaliers and an MASS of ghosts followed soldiers while capturing a renowned country.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Products and consumers have a never ending relationship.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

As far as virtual functions are concerned, they definately incur some performance overhead, but in normal senarios, the cost and nightmares of maintaining repeatitive code is far more than that when virtual functions are used.

The most important point you have to consider while using virtuals is that the binding is done at runtime as compared to when the code is repeated, in which case the binding is compile time.

Also a very important thing which mars the performance of virtual functions is that they can't be inlined. So if you are repeatedly calling chunks of code with the virtual tag attached, you suffer a great performance hit.

Then again, it boils down to what kind of design you have used in your project, but still the cost of setting up vptr's and not having the ability to inline has to be taken in consideration.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

amber -> ruby