Salem 5,265 Posting Sage

> while ((suma = punto) && (suma !=7))
Perhaps you meant ==

Salem 5,265 Posting Sage

> p1 = w1/g2*100;
Should this be g1 ?

Also, try p1 = w1 * 100 / g1; to preserve the precision.

Salem 5,265 Posting Sage

Better check your popen() manual, because most implementations are uni-directional.
Either read-only, or write-only.

Salem 5,265 Posting Sage

You can't do modulo on floats.

Salem 5,265 Posting Sage

> why should we be concerned about the quality in the early increments
Would you buy a car, if you knew that the "quality" was just the coat of paint applied at the last step in production?

Quality is built in to the product from the beginning, not some afterthought applied right at the end.

Salem 5,265 Posting Sage
FILE *fp = popen("myprog.exe", "r" );
while ( fgets( buff, sizeof buff, fp ) != NULL ) {
  // do stuff with lines
}
pclose( fp );

Use _popen() on windows.

Alex Edwards commented: You deserve more than just +1 for all the help you give, but here you go. +2
Nick Evan commented: I'll make it +9 then +8
Salem 5,265 Posting Sage

If we asked for more code, would you still post it without code tags?

Salem 5,265 Posting Sage

Use process explorer from www.sysinternals.com to search for the exe to see what other programs (say virus scanner) may have some kind of access to the file which is preventing you writing to it.

Salem 5,265 Posting Sage

Gee, someone else who can't read the forum rules.

NO FREE HOMEWORK.

In other words, you post some effort to solving the problem, not merely copy/pasting your assignment.

Salem 5,265 Posting Sage

You only test game outside your for loop, yet it could be incremented many times in between each test in your while loop.

Add && game <= 1000 to your for loop condition as well.

The indentation could be a little better as well.

Salem 5,265 Posting Sage

Well if the address is consistent from one run to another, then you could set a hardware breakpoint to trap whenever that location is written to.

That would then point you directly at the line of code which is messing with the memory it shouldn't be.

Salem 5,265 Posting Sage

You seem to have used a really small font with the code.
Can you post it larger please?

Salem 5,265 Posting Sage

C++ compilers compile C++ programs.

This "pure" of which you speak (or portable as we would say) would be the standard library which is documented by ISO.

That said, any program you write which sticks to ONLY using the ISO standard library should
a) be compilable by any implementation of C++ which conforms to the ISO standard.
b) produce the same results when executed.

But all implementations have a whole range of implementation specific things as well (eg. windows.h) which are not portable.

> Or did you just mean that Visual C++ implements the C++ language?
That's pretty much what "is an implementation" is.

Salem 5,265 Posting Sage

C++ is a language, as defined by ISO.
Visual C++ is an implementation (like Borland, GNU, Intel).

Any modern 32-bit compiler will probably meet your needs for learning C++.

Salem 5,265 Posting Sage

Perhaps the compiler has statically determined that the code can never be called, and has thus removed it.

But as jesseb07 says, we need code.

Salem 5,265 Posting Sage

The compiler needs the template code in scope (ie, the header file) if it is to instantiate the template for the required type, be it int or whatever.

Salem 5,265 Posting Sage

Did you put the template code in a header file ?

Did you include that header file in the places where you use SortedType ?

Salem 5,265 Posting Sage

Sure, just use the "add with carry" instruction, and you can add as many as you like.

Salem 5,265 Posting Sage

You also need to add the .cpp file to your project, which implements those functions (in the header file).

Salem 5,265 Posting Sage

Whitespace makes no difference to run-time performance.
Neither do comments.

Salem 5,265 Posting Sage

Try putting the filename variable in quotes in other places as well.

Salem 5,265 Posting Sage

Well if your user input is going into where argv[1] is stored, and you type in a longer name, or you don't supply an argument and you type something (anything) in, then yes, your code is in trouble.

Salem 5,265 Posting Sage

> I thought I typed wrong here.
What!!???

You mean that code isn't a direct copy/paste from your code editor?

Because if it isn't, you're wasting everyone's time.

> char* url = rtspServer->rtspURL(sms);
Post that method.
Are you sure that delete [] url; is valid at that point?

> char* inputFileName=argv[100];
Notwithstanding the point AD made, you also seem to use this as some local variable for reading in user input as well.
Try using a true std::string for reading input.
Ditto with your use of scanf, use a C++ equivalent.

Salem 5,265 Posting Sage

Another problem (or two) would be.

1. Why are you using O_RDWR on both ends?

2. In the receiver, you should test retval for success/fail before testing with FD_ISSET for any descriptors which may have received data.

Post your latest code.

Salem 5,265 Posting Sage

http://www.nist.gov/dads/HTML/avltree.html

If you pick your root unwisely, your BST may resemble a linked list.

Also consider
- the cost of constructing the tree in the first place
- the cost of keeping it balanced
- the number of searches performed
- the distribution of search results.

You need the whole program scenario to make an accurate judgement.

Salem 5,265 Posting Sage

Step 1 would be to remove ALL the gotoxy() and clrscr() and any other decorative features until you've actually got the damn thing to work.

Adding eye candy to an already working program is trivial, compared with trying to maintain it whilst you're debugging the code.

Salem 5,265 Posting Sage

Scope perhaps?

if( TTF_Init() < 0 )
   {
	   return 1;
   }

   {
      Font thing;
   }
   TTF_Quit();

Or call another function.

void foo ( ) {
  Font thing;
}

int main ( ) {
   if( TTF_Init() < 0 )
   {
	   return 1;
   }

   foo();
	
   TTF_Quit();
}

Basically, it's just forcing the destructor to be called before Quit.

Salem 5,265 Posting Sage

The first parameter is
MAX value of the fd's + 1.
Passing 1 means you're just looking for fd0 (aka stdin).

My guess is it should be i+1, but i is a terrible name for a file descriptor.

Salem 5,265 Posting Sage

Your 2nd program isn't doing anything until you fix your select call.

Salem 5,265 Posting Sage

Only if you intend to turn the damn thing off by making sure there's nothing to accumulate.

Salem 5,265 Posting Sage

Read the man page for select, and concentrate on what the first parameter should be.

Salem 5,265 Posting Sage

OIC, the header in question is "stdafx.h".
Well, that's a completely different story.

The easy thing to do is simply delete that line from your source code, and then goto your project settings and turn OFF precompiled headers.

But if you're going to use precompiled headers, then EVERY source file needs to look like this

/* Every source file needs these headers */
#include <iostream>  // just an example
/* The precompiled header magic marker */
#include "stdafx.h"
/* any header files unique to a source file */
#include "myheader.h"

The point being that if every source includes the same thing before stdafx.h, then the compiler only has to do it once (hence, pre-compiled headers!). This (apparently) is a worthwhile performance improvement, but it really appears far too often as a question to be that useful IMO.

It should be off by default, because by the time it's useful, you should know what you're doing. For everyone else (newbies and the people who help them), it's just annoying.

Oh, and another reason for getting rid of it - you want to use Linux at some point.
It's only the microsoft compilers which use it AFAIK.

Salem 5,265 Posting Sage

> But if don't want an array why the compiler chooses to pad the end?
How is the compiler supposed to know you don't want an array of them?

> why "pay" 24bytes when we can fit the whole composite struct in 20 and at the
> same time respect the boundary alignment?
The compiler isn't allowed to rearrange structure members to achieve the best fit.
If you want to arrange things so that you waste the least space, then arrange as groups of double, float, long, int, short, char.

double, char, double, char will take more space than
double, double, char, char

> Deleting padding is useful when you want to save data in binary form to a file
> or xmit it across socket and you don't know what is on the other end.
But packing in itself is not enough to ensure success. Packing can never solve the endian problem for example. Also, packing increases the complexity (and decreases the performance) of the code accessing the structure. On some machines, reading a packed int may take 4 byte reads and some shifting, compared to a single aligned 32-bit read if the compiler was free to do it's own thing.

Another also, does pack() actually guarantee a minimum, or just a "best effort"?

Plus there's the whole "lack of portability" in specifying such things to the compiler to begin with.

Salem 5,265 Posting Sage

Now remove the fread() which is inside the loop (line 13)

Salem 5,265 Posting Sage

Well did you take account of the fact that usleep takes MICROSECONDS?

delay(1000); and usleep(1000); will wait for different times.

Salem 5,265 Posting Sage

Maybe post what you changed it to, rather than just describing the delta.
More often than not, you haven't done it.

Salem 5,265 Posting Sage

http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1046476070&id=1043284351
Test the result of the read operation.
EOF is a state set after the event, not a prediction of the future.

Eg. while ( fread( &hardware, sizeof( struct hardwareData ), 1, readPtr ) == 1 )

Salem 5,265 Posting Sage

Knowing how to program is far more important than being able to write a for loop in 20 different languages.

Being able to construct a meaningful program in any language counts.

Writing "hello world" or a bunch of typical homework assignments in many languages doesn't.

Salem 5,265 Posting Sage

So 10 posts in, it becomes an actual problem rather than something theoretical.
Is it going to be another 10 posts before we see an actual example and some actual error messages?

Not the whole code, just the headers (and the error message(s) of course).

Salem 5,265 Posting Sage

> how do you know what the order is? for pointers?
If the order is right, it compiles.
If the order is wrong, then you'll get "missing declaration" type errors when you compile.

> So if the code file1.h needs to be executed before the code in file2.h (for some reason)
But compiling is not executing. #include is all about declarations, not program execution order. In other words, this works.

#include "func1.h"
#include "func2.h"
int main ( ) {
  func2();
  func1();
}

> well yea but like is there a list of the necessary order?
Read the manual pages for the libraries you're using. If they have multiple headers, they should tell you the order.

> and where would rom be located?
An example would be a chip on your motherboard with "BIOS" written on it. Each CPU needs a small amount of ROM to get things going from a power up. A really simple BIOS in a PC for example only needs to load the boot sector from disk and then jump to the loaded RAM location.
But there are many varieties of persistent memory.
http://en.wikipedia.org/wiki/Non-volatile_memory

Salem 5,265 Posting Sage

Is sizeof(ARP_HEADER) what you expect?
In other words, is padding and alignment an issue?

Salem 5,265 Posting Sage

1. Sometimes it does. Though standard headers tend not to care so much.
2. Mostly true. You can point to constants in ROM, but dynamic memory (as the name suggests) is RAM.

Salem 5,265 Posting Sage

Er, there seem to be some awfully large gaps in your basic C++ knowledge to be writing a game.

File I/O is the first thing you typically learn how to do.

Salem 5,265 Posting Sage

Sure.
All you need to decide is which variables you have in your game which are necessary to restore the state of the game.

Salem 5,265 Posting Sage

Print what you want on separate lines, then use uniq ?

Salem 5,265 Posting Sage

As they say, ASCII stupid question, get a stupid ANSI ;)

Salem 5,265 Posting Sage

uniq works on lines, not characters on the same line.

Salem 5,265 Posting Sage

> $result="$result $next"
Remove the first $ perhaps?
Like your other assignment earlier on.

Salem 5,265 Posting Sage

Breeture.h includes world.h
world.h includes Breeture.h
and so on....

You can't have two classes containing instances of the other class. One of them needs to contain only pointers.

class world;
class Breeture {
  world *w;  // ONLY pointers to worlds in this class
};

and

#include "Breeture.h"
class world {
    Breeture b;  // free to have instances in this class
};
Salem 5,265 Posting Sage

Try using / and %