Forum: C++ Aug 23rd, 2007 |
| Replies: 11 Views: 4,971 Just because you've never needed it doesn't mean that it should never be used. My original point was simply that one should know both sides of an argument like that, and realize that many people... |
Forum: C++ Aug 22nd, 2007 |
| Replies: 3 Views: 739 it sets endwait to be the current clock() value (presumably a timestamp) + a time to wait. It then goes into an empty loop until the clock() value becomes equal to endwait, at which point it exits... |
Forum: C++ Aug 22nd, 2007 |
| Replies: 11 Views: 4,971 Not all professionals refuse to use goto, or else the Linux kernel stopped being updated some while back. Goto sometimes is very useful; just because it's hard to use properly doesn't mean it should... |
Forum: C++ Aug 21st, 2007 |
| Replies: 11 Views: 4,971 They'll probably tell you to never use goto as well, but that doesn't mean you should just listen to them. Find out why, and then do what is best; and yes, the popular opinion can be wrong... |
Forum: C++ Jul 24th, 2007 |
| Replies: 10 Views: 2,280 Be more specific as to what's wrong with them. And please use and tags when posting code. |
Forum: C++ Jul 24th, 2007 |
| Replies: 14 Views: 3,856 So, VC5 isn't one of them. Although I think the standard says an int-compatible type or somesuch, so a pointer would fit that... |
Forum: C++ Jul 20th, 2007 |
| Replies: 14 Views: 3,856 Like others have said, main's return value is used to determine if the program ran successfully or what the errors were. As to why the mechanism is a return value, when your program runs, something... |
Forum: C++ Jul 20th, 2007 |
| Replies: 7 Views: 5,828 If you're using Strings in C#, I think the Format method will be fine. quick example:
String s = String.Format("Card serial: {0} {1} {2} ...", ResultSN[0], ResultSN[1], ...); I don't know that... |
Forum: C++ Jul 16th, 2007 |
| Replies: 62 Views: 9,541 Are you trying to make an ass out of yourself? |
Forum: C++ Jul 15th, 2007 |
| Replies: 62 Views: 9,541 Aside from dot syntax (which most likely preceeds C), how are they related? |
Forum: C++ Jul 7th, 2007 |
| Replies: 13 Views: 1,394 The problem is that you're using integer division, which returns an integer value. Cast the numerator to a double and it should work: daysOffAvg = (double)totaldayoff / numemployees;
... |
Forum: C++ Jul 7th, 2007 |
| Replies: 4 Views: 7,597 Maybe the function isn't defined in any of your source code files? |
Forum: C++ Jul 7th, 2007 |
| Replies: 2 Views: 1,457 *itr returns a string, not a char*. Use the .length() for the string instead. |
Forum: C++ Jul 3rd, 2007 |
| Replies: 7 Views: 3,787 dougy, if either one is NULL, you'll dereference it at least once in the loop body. It's little mistakes like this that make those library functions so important... :icon_wink: |
Forum: C++ Jul 2nd, 2007 |
| Replies: 7 Views: 3,787 Not using strcmp because it's an "external function" is stupid (if this is an assignment, it's a horrible requirement). Especially when the external function doesn't relate to the problem (sorting).... |
Forum: C++ May 29th, 2007 |
| Replies: 3 Views: 3,336 I'd guess that it's due to how floating point values are stored imprecisely in memory, causing the weird results to come up on rare occasions. |
Forum: C++ May 27th, 2007 |
| Replies: 47 Views: 9,093 As Rashakil says, when you have a stack allocated variable, the stack pointer will be incremented to account for it at the beginning of the function. This is much different from allocating on the... |
Forum: C++ May 27th, 2007 |
| Replies: 7 Views: 1,065 I'd say to just keep writing code for now, when you get to the 4-year school they'll have plenty of resources. You might consider reading a couple books on algorithms or software development, and... |
Forum: C++ May 27th, 2007 |
| Replies: 5 Views: 2,183 True, but the error was because it should only be one. |
Forum: C++ May 22nd, 2007 |
| Replies: 12 Views: 1,860 Yes, the use of & is optional in this case. Similarly, when calling the function *foo() and foo() will also be the same. |
Forum: C++ May 22nd, 2007 |
| Replies: 14 Views: 3,568 I don't see the word screen anywhere in his post... |
Forum: C++ May 20th, 2007 |
| Replies: 2 Views: 1,045 Yes, you need to do it. You should also read some of the rules (http://www.daniweb.com/techtalkforums/announcement8-2.html). |
Forum: C++ May 18th, 2007 |
| Replies: 4 Views: 3,638 Also, strcmp will tell you the relative ordering of the strings rather than simply if they are equal, if you needed that as well. |
Forum: C++ May 17th, 2007 |
| Replies: 47 Views: 9,093 I believe the standard sets no rules for any type except char. I don't have a copy of it though, so take it as is. |
Forum: C++ May 16th, 2007 |
| Replies: 47 Views: 9,093 Then it would just be a substr method, and not interesting at all. |
Forum: C++ May 15th, 2007 |
| Replies: 47 Views: 9,093 Ah. I'd assumed that the expert level encompassed the intermediate as well. |
Forum: C++ May 15th, 2007 |
| Replies: 47 Views: 9,093 Aw, c'mon. You can do the intermediate level. Please? :P |
Forum: C++ May 15th, 2007 |
| Replies: 47 Views: 9,093 Again, broken. Test case: extract_digits(5, 2, 4) |
Forum: C++ May 15th, 2007 |
| Replies: 47 Views: 9,093 Hm... I like Rashakil's solution. It's more elegant than anything I would have come up with. Unfortunately, I think I broke it. Test case: extract_digits(-1, 9, 3) which causes a bad index into... |
Forum: C++ May 14th, 2007 |
| Replies: 17 Views: 6,444 Please don't use bold text when you post. It's meant to give emphasis to parts of a post, not the entire body; using it too much is poor netiquette. Also, please use and tags when posting code... |
Forum: C++ May 10th, 2007 |
| Replies: 15 Views: 2,260 Different solution using stringstreams:
#include <sstream>
#include <string>
#include <iomanip>
using namespace std;
string foo(string city, string state)
{
stringstream ss;
string str; |
Forum: C++ May 10th, 2007 |
| Replies: 4 Views: 783 Post your code and we'll take a look at it. :) |
Forum: C++ May 9th, 2007 |
| Replies: 3 Views: 6,153 If you're copying something, you need to allocate memory and then copy the appropriate values in. When dealing with strings, however, there's several library functions that'll help you along the... |
Forum: C++ May 3rd, 2007 |
| Replies: 13 Views: 3,136 No, don't, it would always be false. A number can't be less than 0 and greater than 4. Instead, try moving your second line cin>>grad[i]; into the while loop. Right now it just outputs the warning... |
Forum: C++ May 3rd, 2007 |
| Replies: 10 Views: 1,583 My crystal ball tells me you're calling pop() before you've called push(). It could also be due to a mismatch.
For more detailed analysis, provide more details, such as how the stack works or an... |
Forum: C++ May 3rd, 2007 |
| Replies: 15 Views: 4,263 Is it getting the day counts right though? Maybe if you just rearrange the values for the days it'll straighten out... |
Forum: C++ May 3rd, 2007 |
| Replies: 15 Views: 4,263 Nope, you've got the loop. Remember, j is going from 1 to the current month. So if you pass j, it'll look up the days in the 1st, 2nd, 3rd, ... nth month. :icon_wink: |
Forum: C++ May 3rd, 2007 |
| Replies: 15 Views: 4,263 I actually didn't test the leap year code. What's happening is you're adding the last year before it's over, skewing the result by that number of days. Ditto with the month. If you change the <=... |
Forum: C++ May 3rd, 2007 |
| Replies: 15 Views: 4,263 You add an extra year to the result, plus the number of days in the selected month. January 1800 comes out as 396, or 365+31. |
Forum: C++ Apr 30th, 2007 |
| Replies: 2 Views: 822 Out of curiosity, could your printing code have an off-by-one error to print the same data for the last char in one row and the first in another? |