Forum: C++ Aug 21st, 2007 |
| Replies: 11 Views: 4,772 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 18th, 2007 |
| Replies: 4 Views: 3,555 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++ Apr 13th, 2007 |
| Replies: 4 Views: 5,811 Floating point numbers are not stored precisely in memory. They are usually stored according to the IEEE 754 (http://en.wikipedia.org/wiki/IEEE_754) standard. If you want exact precision, you need... |
Forum: C++ Apr 12th, 2007 |
| Replies: 10 Views: 1,752 The one problem I see is that you can't compare floating point numbers directly. Here's a re-write with slightly different logic (you can keep yours if you want, they're about the same) and a better... |
Forum: C++ Apr 11th, 2007 |
| Replies: 6 Views: 926 The answer (http://www.daniweb.com/techtalkforums/announcement8-2.html) |
Forum: C++ Apr 6th, 2007 |
| Replies: 6 Views: 1,258 1gig encryption? 2mb compression? What do those mean? Are you using a 8589934592 bit encryption key? This isn't making sense. Also, the 2 seconds to encrypt-decrypt: are those for each database... |
Forum: C++ Apr 1st, 2007 |
| Replies: 11 Views: 4,299 While I think my code is readable, that certainly doesn't mean it's the best solution to the problem :p
Code:
#include <iostream>
#include <iomanip>
#include <cstdio>
using namespace std;
int... |
Forum: C++ Mar 31st, 2007 |
| Replies: 5 Views: 1,020 It depends on what I'm doing as to what I'll use. Also depends on the computer I'm on. For helping people on the forums here, I tend to just use gcc from the command line (and a console text... |
Forum: C++ Mar 5th, 2007 |
| Replies: 6 Views: 4,151 if (first != nil)
{
first = newnode;
} I'm just not seeing a reason for even having this part. You know first != nil because you set it above. And if you set first = newnode, you'll lose the... |
Forum: C++ Feb 18th, 2007 |
| Replies: 2 Views: 1,858 Did you read his code? It's done that way. :rolleyes:
Here's the output I get running it:
Data type Size
char 1
unsigned char 1
short int 2... |
Forum: C++ Feb 3rd, 2007 |
| Replies: 10 Views: 3,797 I'd take stable-matching/marriage off that list, since it's much easier to do in a loop. Min-max would be a suitable replacement, however, it might be too complex for a basic example.
@OP:... |
Forum: C++ Dec 6th, 2006 |
| Replies: 6 Views: 1,432 so, here's the output I get from running it (I made a few changes to the code, but nothing to affect the logic, and the lines starting with $ are where I start the program):
$ ./a.out
Please... |
Forum: C++ Dec 6th, 2006 |
| Replies: 10 Views: 3,546 I'm surprised your teacher isn't allowing for lazy deletion. That said, here's one method (I don't remember the best way though) for deleting from a BST:
Find the node to be deleted. From there... |
Forum: C++ Dec 4th, 2006 |
| Replies: 5 Views: 8,135 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++ Sep 16th, 2006 |
| Replies: 2 Views: 1,548 If you have someIstream >> someString it will read up to the first whitespace. Try getline(infile, name) after you get the 3 integers. (I haven't used C++ for a while, so I might be remembering... |
Forum: C++ Sep 16th, 2006 |
| Replies: 4 Views: 1,157 Please don't double post (http://www.daniweb.com/techtalkforums/thread55213.html) |
Forum: C++ Sep 16th, 2006 |
| Replies: 11 Views: 2,874 That error looks like you've got a Visual C++ project expecting a precompiled header (VC++ usually calls it "StdAfx.h" or something, IIRC). I havent used VC++ in a long time, but you'll probably... |
Forum: C++ Sep 14th, 2006 |
| Replies: 4 Views: 5,473 Yeah, you can use eof(). If you read the example in the link I posted, you might get duplicate data.
The problem with the code segment you just posted is that you're still not reading anything... |
Forum: C++ Sep 14th, 2006 |
| Replies: 4 Views: 5,473 First off, lets look at two code segments. The first is your original while loop, the second is writeTotal.
/* ... */
// the while loop:
while (!inStream.eof())
{
... |
Forum: C++ Sep 14th, 2006 |
| Replies: 12 Views: 1,929 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,929 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,929 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,395 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 12th, 2006 |
| Replies: 6 Views: 1,443 A bad habit is a bad habit, no matter what size the program is. Sure, it can be easier for a small program, but that doesn't change things. Same could be said for goto. ;) |
Forum: C++ Sep 9th, 2006 |
| Replies: 10 Views: 11,619 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? |