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,974 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,974 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++ May 29th, 2007 |
| Replies: 3 Views: 3,351 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: 7 Views: 1,066 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 22nd, 2007 |
| Replies: 12 Views: 1,861 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,589 I don't see the word screen anywhere in his post... |
Forum: C++ May 14th, 2007 |
| Replies: 17 Views: 6,459 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,264 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 9th, 2007 |
| Replies: 3 Views: 6,165 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: 15 Views: 4,264 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,264 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,264 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,264 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 27th, 2007 |
| Replies: 17 Views: 3,286 That's about what WaltP suggested :icon_wink: |
Forum: C++ Apr 25th, 2007 |
| Replies: 2 Views: 1,775 It depends on the function you're calling. It could be defined as void foo(T* someArray, int arraySize, int otherValue) or as void foo(T* someArray, int otherValue, int arraySize). The second one... |
Forum: C++ Apr 19th, 2007 |
| Replies: 23 Views: 2,169 Your code really needs to be indented for readability purposes.
Anyways, global identifiers are typically considered bad style. They still work, but if you can come up with a solution without... |
Forum: C++ Apr 14th, 2007 |
| Replies: 17 Views: 3,286 If you're using C++, you should probably be using the std::string type rather than C-style strings (char*).
And your line strlen(getWord) = numLetters; is backwards. Try flipping it around. ;) |
Forum: C++ Apr 9th, 2007 |
| Replies: 14 Views: 5,378 How are you currently sorting them? |
Forum: C++ Apr 9th, 2007 |
| Replies: 14 Views: 5,378 vijayan's solution should be correct. There's a few things different between his and yours, though, which are important. First, his parameter takes a const object. This allows you to have a const... |
Forum: C++ Apr 1st, 2007 |
| Replies: 2 Views: 3,769 Just looking at the code for display, I'm surprised it doesn't crash.
void doubly::display()
{
node *temp;
temp=head;
while(temp!=NULL)
{
cout<<temp->data<<"\t";
... |
Forum: C++ Mar 15th, 2007 |
| Replies: 2 Views: 2,242 You seem to be leaving out braces on your if statements. It was really easy to find with the code auto-indented. Here's a code excerpt:
switch (pkgType)
{
case 'A':
if... |
Forum: C++ Mar 5th, 2007 |
| Replies: 6 Views: 4,228 Ok, a list of things.
First, as Lazaro pointed out, main should be type int, not void. A return 0; is then implied, but most people add it for clarity's sake.
Second, on a matter of style:... |
Forum: C++ Mar 5th, 2007 |
| Replies: 6 Views: 4,228 Lazaro, please do everyone else a favor and don't quote hugely long threads for a one line reply. Or, if you're quoting to that your reply has context, please trim the quoted part as much as... |
Forum: C++ Feb 28th, 2007 |
| Replies: 29 Views: 2,877 when [ left] got parsed out ;) |
Forum: C++ Feb 28th, 2007 |
| Replies: 29 Views: 2,877 You're getting close, but you're still missing some things. For instance, if left > size, you don't return anything, which should be a compiler error. You did try to compile the code first, right? ... |
Forum: C++ Feb 28th, 2007 |
| Replies: 29 Views: 2,877 Try running through your code on paper, as though you were the computer. You'll see that you're not using the left variable for anything, except the +1 before recursing. And you'll recurse... |
Forum: C++ Feb 15th, 2007 |
| Replies: 4 Views: 5,274 Ancient Dragon's example will work for the first elemend of the 2D vector, and you'll probably have to nest it to go through all the rows of the 2D vector. |
Forum: C++ Feb 11th, 2007 |
| Replies: 7 Views: 1,104 The easiest way would probably be to take the input as a string and compare each character to '1' and '0'. This will also help you tell if the user entered something like "101234" or "16oz." |
Forum: C++ Dec 13th, 2006 |
| Replies: 7 Views: 3,336 1) Where is _strdate() defined? I'm not finding it...
2) Why are you using <iostream> and <stdio.h> (which should be <cstdio>)? |
Forum: C++ Dec 4th, 2006 |
| Replies: 5 Views: 8,296 The #include "myheader.h" will essentially paste the contents of myheader.h into the top of whatever file it is #included into. So it'll be comiled just fine. In order to get the .cpp file... |
Forum: C++ Dec 4th, 2006 |
| Replies: 5 Views: 8,296 When you run a program, the program starts with the main() function by definition. You need a main() somewhere in your project, and whatever file contains main() should be the one you compile to... |
Forum: C++ Oct 20th, 2006 |
| Replies: 9 Views: 1,891 1) Post some code. Unfortunately, crystal balls are a bit out of the budget, so we can't see what's wrong.
2) A 9-year old book is... well, almost antiquated. Consider getting a new one, since... |
Forum: C++ Sep 14th, 2006 |
| Replies: 12 Views: 1,943 This is because it reads the number, then the loop condition fails so it doesn't save the number. I'll let you figure out a way to fix that ;) |
Forum: C++ Sep 13th, 2006 |
| Replies: 12 Views: 1,943 I made a few changes to the code, mostly small ones, but here's what I've got atm:
#include <fstream>
#include <iostream>
using namespace std;
const int MAXLEN = 10;
int buffer[MAXLEN];
int... |
Forum: C++ Sep 13th, 2006 |
| Replies: 12 Views: 1,943 I'd first off recommend using return types instead of pointers. Handling pointers like that (imho) just makes the code messier than it needs to be. You could do it with references instead of... |
Forum: C++ Sep 12th, 2006 |
| Replies: 3 Views: 1,421 The easiest way would be to put a big loop around the main part. You could have your menu contain an extra option to quit, and just keep doing calculations until they enter that option. |
Forum: C++ Sep 9th, 2006 |
| Replies: 10 Views: 11,995 I don't see the reason for the 3rd loop for(int k = 0; k < 14; k += 2)
cout << endl;
You'll be outputting 7 newlines between rows of stars... is that what you meant to do? |