User Profile
Collapse
-
What Ganon11 said, plus it's good style to use capital letters for your symbolic constants (MAX1, not max1) so that they don't look like variable names. -
What you have should work, in the dispStudent function you can display the last name like this:
cout << stu.last;
However, I'd do it a little differently. When you declare the function dispStudent, instead of declaring it like this:
void dispStudent(Tst udent stu) /* passes a copy of the entire struct */
I would declare it like this:
void dispStudent(Tst udent * stu) /*...Leave a comment:
-
What kind of message do you get when execution halts? And how do you know that it's happening right there? Also, it would help if you showed us the declarations for your variables so we know their types.Leave a comment:
-
Did you set the graphics mode first? If so, what resolution did you set? Are you using the Borland graphics library?
You have an off-by-one error, your for loops should use the < operator instead of <= for the stop condition.
Also, an unsigned char has a maximum value of 255, signed short has a max value of 32767, and unsigned short has a max value of 65535.Leave a comment:
-
To test if the address is divisible by 4, you can use modular division, like this:
if ((int)&var % 4 == 0) { ... }
Note, however, that from a logical standpoint, showing that a particular variable is 4-byte or 8-byte aligned does not prove that the compiler always does it that way. I think you could spend quite a bit of time trying to devise ways to demonstrate that the compiler is actually doing alignment. I think the best...Leave a comment:
-
In this case, the best answer is probably the most obvious one: instead of just one score ("finalGrade "), use 4 different variables for the scores instead....Leave a comment:
-
The behavior is undefined by the standard, as Jos said, but obviously a particular compiler implementation defines a behavior, whatever that may be. It might be fun to poke around and figure out what that behavior is. You should never write any program that depends on that behavior though. Even if you are targeting only one particular compiler and you know how it behaves regarding this issue, there's no guarantee that it won't change tomorrow. (In...Leave a comment:
-
Re-examining the output, I see that this is the case. The next_permutatio n function assumes it has finished when the series is in reverse order. (Otherwise it wouldn't know where to stop.) Thus, if you don't start with an ordered series, some of the permutations will be skipped.Leave a comment:
-
From this documentation of next_permutatio n --
http://www.sgi.com/tech/stl/next_permutation.html
-- it seems that the function might not work if your original series is not sorted in non-descending order.
It says, "There is a finite number of distinct permutations (at most N! [1], where N is last - first), so, if the permutations are ordered by lexicographical _compare, there is an unambiguous definition...Leave a comment:
-
You could use the sqrt function to compute the square root of a given number, but since it uses a double-precision floating point value, your results may be slightly off from the true answer. You will probably want to test whether the result is *almost* an integer, i.e. less than 0.0000001 off from an integer value or something like that. If the square root is an integer (or "close enough"), then the number you started with is a perfect...Leave a comment:
-
Sounds like you do want to use asynchronous sockets.
http://www.gamedev.net/reference/pro...res/asyncsock/
I can't answer the question about OpenGL, maybe someone else can....Leave a comment:
-
Surprising but easily explained, it would seem that the VC grammar defines argument lists in a right-recursive manner so that the rightmost term is the innermost level of the syntax tree and is evaluated first.Leave a comment:
-
-
When you plan to make your code portable, usually the best approach to start with is to avoid using platform-specific features. Use standard libraries to do what you need. The standard libraries have many limitations, though, so sometimes you need to go beyond them.
Often the best solution is to use a cross-platform library that does what you need. That way, the library maintainers do the work of customizing for each platform on which...Leave a comment:
-
Not that I'm trying to spoil your cleverness, hehe!
Also, I meant to write: i = yourString.inde xOf(charToCount , i);
So it works instead of looping infinitely.Leave a comment:
-
I would argue that you should NOT think of that... "creative" code is harder to read!
Code:int count = 0; int i = 0; while (true) { i = yourString.indexOf(i); if (i == -1) break; i++; count++; } return count;
Leave a comment:
-
If you mean that you should instantiate Engine, Window and Wheel in the main method of your TestCar class, then yes, I agree....Leave a comment:
-
You're right, there are some problems with the last 2 classes.
In class Car, you are initially assigning default objects to your engine, wheel and window variables, but there's no need for that because they get assigned by the constructor. Also, "point1" and "obj1" are not appropriate names for variables, give them names that relate to what they represent.
In class TestCar, you can't just instantiate...Leave a comment:
-
The OS can be detected automatically but it takes a lot of arcane tricks, there's no one simple way to do it that quickly gives you an answer for every OS. The easiest way to get the kind of functionality you're looking for is to use a 3rd party library that does the detection for you. Libraries that are designed to be cross-platform usually define preprocessor symbols that you can use for your own purposes as well. Also, autoconf can help you find...Leave a comment:
-
The standard function to get the current time is called, unsurprisingly, "time".
http://www.hmug.org/man/3/time.php
Unfortunately, the time function counts in seconds, and for your purposes it looks like that's not enough precision. If your system has it, you can use gettimeofday, which returns the time in milliseconds.
http://www.hmug.org/man/2/gettimeofday.php
I don't think Windows has gettimeofday,...Leave a comment:
No activity results to display
Show More
Leave a comment: