nezachem 616 Practically a Posting Shark

Depends on how the executable (which you refer to as cpp) expects the input:
1. It reads the filename:

echo file1.xml | ./a.out > 3d-1.xml

2. It reads the contents of a file:

./a.out < file1.xml > 3d-1.xml

3. It takes a filename as an argument:

./a.out file1.xml > 3d-1.xml

All of the above presumes that a.out writes its output to stdout.

nezachem 616 Practically a Posting Shark

At line 41, you always comparing t against s[1...], no matter how deep you are in the enclosing loop. If the string has a pattern at position 1, you'll match it many timers. Otherwise, you'll never match it.
In other words, initialization j=1 is wrong.

minimi commented: OMG, Thank you! +2
nezachem 616 Practically a Posting Shark

My recommendation is to sort of forget the most common and effective languages used in industry part, and study languages which represent the extremes of different programming models. It really gives a perspective on what software engineering is about. One possible set includes C, Forth, Haskel, Java, Lisp, Python, and Prolog. Coincidentally, (almost) no time would be wasted, since most of them are pretty much alive in the industry.

nezachem 616 Practically a Posting Shark

Sorry, a typo there. Missed -c:

$ stat -c '%Y' .
1317010317
$

The value is a modtime in seconds since epoch.
Still, which system are you using, and what exactly the manpage says?

nezachem 616 Practically a Posting Shark

What system is this? Also, can you quote more context from the man page?
Because normally to get a modtime one would call

stat '%Y' filename
nezachem 616 Practically a Posting Shark

i put all the header component in one structure. but still the same :(

typedef struct bmpfile_header {
	uint8_t magic1;
	uint8_t magic2;
	uint32_t filesz;
...
} BITMAPHEADER;

Of course. filesz is still naturally aligned at 4 bytes, which requires padding.

what i don't understand is, it works as i expected when it reads from a bitmap file. but not when writes.

You (correctly) read data very carefully, field by field. You shall write the same way you read.
It is very tempting to avoid padding issues with pragma pack (or __attribute__(align) , depending on a compiler). The result will be highly nonnportable, with the whole spectrum of problems from build failures to runtime faults.

nezachem 616 Practically a Posting Shark

The compiler aligns BITMAPHEADER at a 4-byte boundary. Since MAGIC occupies only 2 bytes, the compiler (when laying out the image structure) inserts 2 bytes of padding between magic and head .

nezachem 616 Practically a Posting Shark

Notice that the blocks of code at lines 30-71 and 72-113 are nearly identical. The only difference is that "*" and "o" are swapped. Create a method doMove(String title, String self, String other) , and use it as

for(;;) {
        if(team) {
            doMove(name, "* ", "o ");
            team = false;
        } else if(team == false) {
            doMove(opo, "o ", "* ");
            team = true;
        }
    }

Not only your code becomes twice as short (which means twice less maintenance), you may immediately realize that the team variable is redundant. Really, the game loop becomes

for(;;) {
        doMove(name, "* ", "o ");
        doMove(opo, "o ", "* ");
    }

BTW, you need a way to detect an end of game situation and break the loop.

Now, let's get into the doMove itself. Notice that you test board[a][b] in each clause. Again, a redundancy must be eliminated:

if(board[a][b].equals(self) {
        ... Keep processing the move ...
    } else {
        System.prinln("invalid input");

}

And last but not least, you allow horrible violations of rules.

nezachem 616 Practically a Posting Shark

Just do the same math: In any case, guests * cost_of_chicken must be spent. The rest, that is budget - guests * cost_of_chicken may be used to pay an excess price of steak, that is price_of_stake - price_of_chicken.

steaks = (budget - guests * cost_of_chicken) / (price_of_stake - price_of_chicken)

Am I missing something?

nezachem 616 Practically a Posting Shark

Take a look at GNU plotutils.

nezachem 616 Practically a Posting Shark

I don't know. I'm starting to think I may have imagined something

I think the confusion comes from the overcommit feature of some OSes. Indeed, memory allocation routine may just reserve the address space, and postpone actual mapping until the first access. So an object with the trivial constructor may remain in the aetherial state for a while. However, new would execute exactly when it is called.

mike_2000_17 commented: that makes more sense. thanks +14
nezachem 616 Practically a Posting Shark

AFAIK, it comes from the Cold War times. Then there were superpowers (USA and USSR), developed countries, and the third world.

nezachem 616 Practically a Posting Shark

One fairly obvious problem is at lines 14-15. The way it is written it means that a (phony) target classes depends on nothing, and the recipe is a very strange command. You want classes to depend on the list of class files with no recipe.
Join those two lines together.

nezachem 616 Practically a Posting Shark

At line 42 you call matrixCofact as if it returns the minor's determinant. I recommend to (a) make matrixCofact return double, (b) get rid of its third parameter (you don't use it anyway), and (c) change line 50 to return det . Of course, det should be just double (not a pointer).
PS: minor->elements at line 52 is wrong. It should be mat->elements[0].
PPS: You probably know that it is one of the least efficient algorithms.

nezachem 616 Practically a Posting Shark

Waiting for I/O counts as it constitute to time used by processor for waiting

Waiting for IO uses no processor time. The processor is busy running other processes.

nezachem 616 Practically a Posting Shark

Is example built by you, or did it come with the source code? I suspect latter. Try to

rm example; make example

BTW, second rule looks really strange.

nezachem 616 Practically a Posting Shark

Posting makefile may actually help.

nezachem 616 Practically a Posting Shark

The sed command seems easy to work with, I googled it but I still do not understand the p at the end (-->200p)

By default sed prints every line it works with. The -n option suppresses this (usually unwanted) behaviour. Now that you've get rid of unwanted lines, you still need to print those you need. That's what a p command is doing.

nezachem 616 Practically a Posting Shark

First of all, I don't believe you. The code you gave may not possibly produce more than one line of output (because of break at line 15).

That said
-- line 11 means
(a) test "$line" -gt 100
(b) if (a) returns success (exit code 0), execute the command "$line" -lt 200

-- $line is a contents of the line you've just read, not a sequence number. Taking your word that "result is all of the lines", I suspect that your file consists of numbers, one per line, all of them less than 100 (this is the only scenario in which your script may run with no errors).

Of course the right way to achieve your goal is a sed script:

sed -n -e '100,200p'

If you insist on a pure bash with no external utilities, then

# read and ignore first 100 lines:
for ((i=0; i<100; i++)); do read line; done

# read and echo next 100 lines:
for ((i=0; i<100; i++)); do read line; echo $line; done
# That's it
nezachem 616 Practically a Posting Shark

> What do you mean by that?

Consider the position:
W: Ke1, Rg1, Nf2
B: Kg8, Bg3
Is 1. Nd1 valid?. It passes the "geometrical validity" test, but makes possible 1. ... Bxe1 - the white King becomes exposed even though the Bishop is pinned. In your logic however, you would try to validate 1. ... Bxe1 all the way.

> How else can I do this though WITHOUT using IsValidMove or CanPieceBeTakenByEnemy?

As I said, IsSquareExposed() method is a way to go. Something along the lines of

IsValidMove(from, to)
{
    if(!IsPathOk(from, to))
        return False();
    PretendDoMove(from, to);
    if(IsSquareExposed(kingSquare))
        return False;
    return True;
}

IsSquareExposed(square)
{
    for_all_opponent_pieces(p) {
    if(IsPathOk(p, square))
        return True;
    return False;
}
David_Omid commented: This single piece of advice saved me a LOT of time! +2
nezachem 616 Practically a Posting Shark

checking if the king can be taken by an enemy piece

... shall not be tested for pins. You need a separate method to test for square exposure (instead of generic CanOtherPieceBeTakenAfterPieceMoving).

nezachem 616 Practically a Posting Shark

Good for you. Gdb is a way to go.

Your problem is that you equate a 2-dimensional array to a double indirection. They are different creatures. That's why the compiler warned you, so that you ended up with explicit cast on lines 197 and 199.

When your function sees a char ** list , it expects (loosely speaking) an array of pointers: list[x] must be a pointer. Of course it is not, because the original array does not contain any. With its declaration in scope (that is knowing the row width), the compiler is able to figure out where each row starts.
In a format function this information is lost.
A solution, instead of fooling the compiler with casts, is to declare your true intentions:

void format(char lines[][MAX], count)

and happily get rid of casts.

nezachem 616 Practically a Posting Shark

>well-documented

As a matter of fact, it is. See a link in my post. As for applications working correctly, MSDN specifies that
For a specified hook type, thread hooks are called first, then global hooks. which means that an application is still able to receive all events, and also warns that

The global hooks are a shared resource, and installing one affects all applications in the same desktop as the calling thread. ... Global hooks should be restricted to special-purpose applications or to use as a development aid during application debugging. Libraries that no longer need a hook should remove its hook procedure.

nezachem 616 Practically a Posting Shark

> Bit 31 in lparam tells whether a key is down.

What gives you such idea?

Try an experiment: set a breakpoint at line 6. Press buttons few times. Pay attention to lparam. Be surprised that it doesn't change. Then read documentation, and realize that lParam is a pointer is disguise, and that wParam is press/release info.

nezachem 616 Practically a Posting Shark

They are the most efficient I could possibly make them. Any more efficient and i'd have to write it in assembly.

To begin with, both functions make library calls, which are totally uncalled for. A standard technique here is

while(*in_BinaryString)
        Result = (Result << 1) | (*in_BinaryString++ == '1')

The IntToBinary (which BTW fails for a negative argument) instead of calling memmove should just return Result + t; . Since Result is static, its last byte is initialized to 0 and shall never be touched:

char * IntToBinary(unsigned int in_Integer)
{
    static char Result[MaxLen];
    static char digits = { '0', '1' };
    char * dst;
    for(dst = Result + MaxLen - 1; in_Integer > 0; in_Integer >>= 1)
        *--dst = digits[in_Integer & 1];
    return dst;
}

I do prefer a digits array to a ternary for a reason of branch elimination. Assuming an ASCII code set, one may even do

*--dst = '0' + (in_Integer & 1);
TrustyTony commented: Looks neat +13
nezachem 616 Practically a Posting Shark

I suspect the OP problem is much simpler; it is a purely logical error. Opon the first loop completion, classInfo is the value of the last qualifying trainClassInfo. The second loop always runs all the way through, and the last comparison always evaluates to True.
Solution: exit the second loop as soon as the mismatch is detected.

nezachem 616 Practically a Posting Shark

.wav takes a little more than shoveling it onto a sound card. A starter overview is here, for example.

So, what you need to do is to read and validate the chunk descriptor; read a subchunk 1, which gives you, among other things, a "byte rate"; multiply the byte rate by the number of seconds, and read that amount of bytes from the data subchunk. All of that assuming PCM data.

nezachem 616 Practically a Posting Shark

There's no boolean in C. Any incarnation of zero resolves to false; everything else resolves to true. !fork() is therefore synonymous to fork() == 0

vedro-compota commented: +++++ +3
nezachem 616 Practically a Posting Shark

I am not sure if this is related to your problem, but the receiving loop (lines 7 - 13) looks very suspicious. Is it a copy-paste or you typed it in?

nezachem 616 Practically a Posting Shark

> every byte in a dword gets a separate push mov call sequence, every letter in the text

I am afraid you misinterpret the disassembly. Can you post the disassembler output?

nezachem 616 Practically a Posting Shark

The argument is passed by the OS when the signal is delivered. The rationale is that you may install the same handler for different signals.

nezachem 616 Practically a Posting Shark

Sure.
If you insist on recursive approach, it is better to half the argument, rather than subtract a small decrement. For example, to calculate sin(0.5), your code goes down 50 levels of recursion, while halfing does only 6. Another speedup is achieved by sincos, which calculates both sin and cos simultaneously, and performs faster than any of them:

sincos(double x, double * sin, double * cos)
{
    if(fabs(x) < epsilon) {
        *sin = x;
        *cos = 1.0 - x*x/2.0;
        return;
    }
    double s, c;
    sincos(x/2, &s, &c);
    *sin = 2.0*s*c;
    *cos = c*c - s*s;
}

As a side note, in the base case for sin and tan you should return x instead of SIN/TANMIN (for cos it is 1 - x*x/2).

nezachem 616 Practically a Posting Shark

You created a buffer overflow, and corrupted the stack. Line 17: there's no such thing as s1[40]. The maximal index legal for s1 is 39.

nezachem 616 Practically a Posting Shark

What is m at line 7?

nezachem 616 Practically a Posting Shark

You can't send std.string to fscanf. It expects a C-style character array.

Akill10 commented: thanks +1
nezachem 616 Practically a Posting Shark

How name and pass are declared?

nezachem 616 Practically a Posting Shark

Line 46: How the memory for temp's data is allocated?

nezachem 616 Practically a Posting Shark

Something is wrong here:

kputs:
	; get our first argument address into esi
	push ebp
	...
	jmp kputs

What state is the stack in when the end of string is reached?

It might be worth noting I have no debug tools that I know of available

gdb works fine in a sandbox (not to mention of a remote debug session).

nezachem 616 Practically a Posting Shark

Then the question nails down to what exactly is the virtual spec of that virtual card.

All cards are really different. They all support the lowest common hardware denominator (that is is VGA), and their drivers support the lowest common sofrware denominator (that is, DX/OGL standard). Programming registers of GeForce has absolutely nothing in common with programming registers of Radeon, or Larrabee, or Integrated Graphics, or whatever else.

So, how does your card operate?

nezachem 616 Practically a Posting Shark

> I was wondering how I could display more than 256 colors with the VGA color palette

You can not. It is a fundamental limitation of the VGA architecture. VGA may hold just that many colors at a time.

> the reason that you can't display more than 256 colors at once is because each byte in video memory corresponds to one pixel on the screen

The reason is that the VGA palette has 256 entries.

To achieve true color you must go beyond VGA modes.

nezachem 616 Practically a Posting Shark

Post the latest code then.

nezachem 616 Practically a Posting Shark

> What do you mean, nezachem?

What is name after *name++ ?

nezachem 616 Practically a Posting Shark

While "validating" (line 49 and below) you change name and text. They are not pointing to the correct places anymore.

nezachem 616 Practically a Posting Shark

Of course. I do not expect it to be compliant; the Standard pretty much says that const qualification forbids the qualifiee (for a lack of the better word) to be a modifiable lvalue. It even makes it viral, in a sense of 6.3.2.1-1, which already makes allocation in your original snippet noncompliant. If I am right in my interpretation, my proposal wouldn't do any more harm.

nezachem 616 Practically a Posting Shark
#include <stddef.h>
...
    * (int *) (((char *) sptr) + offsetof(struct mys, value)) = 1234;
nezachem 616 Practically a Posting Shark

man fstat. Study the st_mode field.

nezachem 616 Practically a Posting Shark

When you run into that problem, you will discover that you have 10K lines of code to fix... Be safe. Read the ANSI/ISO C++ standard. They are very clear on this point.

Chapter and verse, please? 18.1-3 totally contradicts to what you say.

nezachem 616 Practically a Posting Shark

Python doesn't like global variables. If you insist on using them, be explicit. Declare them as such.
As for your current arrangement, the assignment at line 13 makes Python think that strPlayer1 is a local variable - it doesn't bother to check its global existence.
Just add

global strPlayer1

to Start()

nezachem 616 Practically a Posting Shark

> The problem is not the pointer

I suppose that now we are in the violent agreement.

nezachem 616 Practically a Posting Shark

Really sorry. Quoting seem to be messed up. More questions to Dani.

>> Sorry for annoyance. Is VC++ 2010 Express compliant?

Yes. What compiler are you using?

None.

>>I had an impression we're not talking pointers in general
That was referring to the printf() line, where the format specifer string uses %d yet only one of the 4 bytes of the integer is in the parameter list.

Huh? this one?

printf("The number is %d",*(char*)p1);

there is a pointer passed there.