Search Results

Showing results 1 to 40 of 53
Search took 0.01 seconds.
Search: Posts Made By: mahlerfive ; Forum: C++ and child forums
Forum: C++ Jan 20th, 2009
Replies: 6
Views: 544
Posted By mahlerfive
Just tested it with the changes mentioned, and it works for me too.
Forum: C++ Dec 26th, 2008
Replies: 4
Views: 737
Posted By mahlerfive
Here are another 2 options:

1) Make a copy of the array, and do only a partial selection sort. Use the variation of selection sort that puts the largest element at the end. Since you only want the...
Forum: C++ Dec 16th, 2008
Replies: 4
Views: 582
Posted By mahlerfive
Your instructor's feedback is extremely straight forward...
Also he did miss some things:
- The US dollar to English pound conversion in your code is incorrect, take a closer look at the conversion...
Forum: C++ Dec 12th, 2008
Replies: 2
Views: 1,408
Posted By mahlerfive
1. recv() will NOT necessarily receive all the bytes sent in one call. You will have to loop it. Since recv() returns the number of bytes received, what you can do is have the sender always put an...
Forum: C++ Dec 9th, 2008
Replies: 1
Views: 316
Posted By mahlerfive
Instead of: int board[4][4];
Replace with: int** board;
Now we can dynamically allocate space for the 2D board array.

In set_board(), we need to do the dynamic allocation like so:

// First...
Forum: C++ Dec 9th, 2008
Replies: 5
Views: 456
Posted By mahlerfive
Also try to keep your indentation a standard width - usually 3 or 4 spaces is good.

As for the non-standard includes as mentioned above, I'm guessing you are using something old like borland or...
Forum: C++ Dec 9th, 2008
Replies: 3
Views: 299
Posted By mahlerfive
Not really sure what you are asking... but if you're asking what sum = sum + 5; does, then the answer is that it increases the value stored in sum by 5.
Forum: C++ Dec 9th, 2008
Replies: 2
Views: 347
Posted By mahlerfive
The other option is to just sort both arrays which will make traversing the arrays and finding non-duplicates much easier.
Forum: C++ Dec 9th, 2008
Replies: 2
Views: 263
Posted By mahlerfive
Well if the output is always zero, then either 5/9 is 0 or F-32 is 0. Try and write a small program that just prints the result of 5/9 and one that prints the results of F-32 after the user enters F....
Forum: C++ Dec 8th, 2008
Replies: 8
Views: 576
Posted By mahlerfive
Not sure where to start on this one... You haven't really followed the instructions. The instructions state that EACH student data record should be dynamically allocated. Instead your student list...
Forum: C++ Dec 8th, 2008
Replies: 6
Views: 371
Posted By mahlerfive
Have you learned about classes in your course yet? If so then you should be using them. If not, you should at least break your functions up into smaller, more manageable functions. Also you should...
Forum: C++ Dec 8th, 2008
Replies: 2
Views: 300
Posted By mahlerfive
Hmm not exactly sure what that would be happening, but there are still a couple things you need to change. At the top you should declare gRow and gCol as const int - I'm not sure how this even...
Forum: C++ Dec 8th, 2008
Replies: 5
Views: 373
Posted By mahlerfive
You are getting mixed up about what should be in your main() and what should be in your class methods.

As the problem specifies, input for a TMoney should be done in the inputdata() method, and...
Forum: C++ Dec 8th, 2008
Replies: 7
Views: 511
Posted By mahlerfive
When adding the node at the end (as you are now doing), you should have the new node point to NULL instead of head. The reason you get it infinitely repeating is because when your end node points to...
Forum: C++ Dec 8th, 2008
Replies: 7
Views: 511
Posted By mahlerfive
What exactly are the requirements? Are you supposed to be adding new nodes to the beginning of the list or the end of the list? Are you sure you are not supposed to get the result you got?

In the...
Forum: C++ Dec 8th, 2008
Replies: 7
Views: 511
Posted By mahlerfive
Since you are adding nodes to the head (start) of the list, the last node you add will be in position 0. The output is correct for the example you gave. I'm assuming the list isn't supposed to be...
Forum: C++ Dec 5th, 2008
Replies: 3
Views: 396
Posted By mahlerfive
To add two times as you have listed, first add the seconds together. If the seconds > 59 you will have to use modulus (%) to find the remainder of the seconds. You can then use this information to...
Forum: C++ Dec 1st, 2008
Replies: 5
Views: 417
Posted By mahlerfive
You're off to a good start, here are some little tips/observations that might help you:

1/ Your header file should contain the structure definition as well as the function prototypes for functions...
Forum: C++ Nov 30th, 2008
Replies: 9
Views: 773
Posted By mahlerfive
It depends on the platform. Since a pointer is an address, it must be big enough to store the largest address. I'm fairly sure that in windows addresses are 32bits (4 bytes). In linux/unix it may be...
Forum: C++ Sep 3rd, 2008
Replies: 11
Views: 2,105
Posted By mahlerfive
Let's look at a simple example of how you might do this. Imagine you were give the number 72061.

The first thing you should do is determine how many digits there are - in this case 5. Now, you can...
Forum: C++ Sep 1st, 2008
Replies: 4
Solved: Input file data
Views: 580
Posted By mahlerfive
It should be readfile >> sample; since you are getting input, not outputting.
Forum: C++ Sep 1st, 2008
Replies: 2
Views: 409
Posted By mahlerfive
There is no real point in writing a "bug-fix class". Essentially the derived class will have to overload all the methods of the base class anyway - so none of the parts of the base class will be...
Forum: C++ Aug 29th, 2008
Replies: 12
Views: 996
Posted By mahlerfive
I just learned some MPI recently and I have a PDF with some basics about how to use it with C (and possibly fortran, i forget). Just PM me your email address and I'll send it over.
Forum: C++ Aug 29th, 2008
Replies: 4
Views: 999
Posted By mahlerfive
The line if (argv[1] == "/e") is invalid since you are compairing a char pointer to a string. To compare strings, use strcmp().

Also, if the user doesn't enter the easteregg argument, you don't...
Forum: C++ Aug 25th, 2008
Replies: 2
Views: 878
Posted By mahlerfive
You can use the built in STL sort algorithm - http://www.cplusplus.com/reference/algorithm/sort.html

Just follow the example at the bottom where they overload the lessthan operator for the class.
Forum: C++ Aug 24th, 2008
Replies: 4
Views: 1,271
Posted By mahlerfive
I have not used them, but I believe the boost library has threads and you can try pthreads as well.
Forum: C++ Aug 24th, 2008
Replies: 10
Views: 1,372
Posted By mahlerfive
The only problem with this method is that if you actually want to send a \n, you are out of luck. The approach I use is to tack on an integer on the front of each message to tell the receiver how...
Forum: C++ Aug 24th, 2008
Replies: 10
Views: 1,372
Posted By mahlerfive
I can guarantee you the problem is not winsock, it is something you are doing.

Can you post a little code where you are having the problem, tell us what you are trying to send and what you are...
Forum: C++ Aug 23rd, 2008
Replies: 2
Views: 478
Posted By mahlerfive
Vertices are the points or corners of a polygon. So a square is a polygon with 4 vertices, a triangle is a polygon with 3 vertices, etc.
Forum: C++ Aug 22nd, 2008
Replies: 10
Views: 3,385
Posted By mahlerfive
First of all, if you want 30 strings of up to 20 characters each, then your declaration should be the other way around, and you need an extra char for each null terminator (the character that ends a...
Forum: C++ Aug 22nd, 2008
Replies: 13
Views: 2,916
Posted By mahlerfive
As someone asking a question, I would much rather prefer answers to be short, few, and useful, rather than have everyone post answers and having to sort out which one is correct. In some things there...
Forum: C++ Aug 22nd, 2008
Replies: 7
Views: 581
Posted By mahlerfive
Both answers are pretty much correct, depending on how you look at it. Passing a pointer to an object is considered passing by reference since the function now has a way to reference the object...
Forum: C++ Aug 22nd, 2008
Replies: 7
Views: 581
Posted By mahlerfive
Oops I forgot to include a passing by reference example.. here it is:


#include <iostream>
using namespace std;

int main() {
int x = 5;
cout << "In main before calling function, x = "...
Forum: C++ Aug 22nd, 2008
Replies: 7
Views: 581
Posted By mahlerfive
A lot of important questions here, so I will try and answer them the best I can.

First, the main difference between passing by value and passing by reference.. When we pass by value, the receiving...
Forum: C++ Aug 20th, 2008
Replies: 4
Views: 1,324
Posted By mahlerfive
This is a prime example of how I see some students graduate in computer science and don't understand basic object oriented programming concepts. You need to figure this out yourself. Of course if you...
Forum: C++ Aug 20th, 2008
Replies: 14
Views: 1,300
Posted By mahlerfive
If you are asking "why is overloading functions useful", then the answer is because sometimes we want two or more functions with the same name which provide the same functionality, but which require...
Forum: C++ Aug 20th, 2008
Replies: 10
Views: 1,088
Posted By mahlerfive
To be a bit clearer, you can use the stringstream class like so:

#include <iostream>
#include <sstream>
using namespace std;

int main() {
stringstream ss; // our stringstream object
...
Forum: C++ Aug 18th, 2008
Replies: 4
Views: 457
Posted By mahlerfive
The way you've structured your headers (.h) and implementation (.cpp) files is not very good and is probably causing the problem.

Typically for a class you should always have a header file which...
Forum: C++ Aug 18th, 2008
Replies: 15
Views: 1,150
Posted By mahlerfive
I agree with Radical Edward - you may save some time switching from vectors to arrays (maybe half the time), but you may be able to structure your data so that you can perform your most often called...
Forum: C++ Aug 18th, 2008
Replies: 7
Views: 2,171
Posted By mahlerfive
Oops, sorry, the post before me was 1 hour ago, didn't check the OP posting time
Showing results 1 to 40 of 53

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC