Forum: C++ May 15th, 2006 |
| Replies: 8 Views: 2,629 I am using dev-c++ 4.9.9.1 and your last code works just fine (Windows XP). I think the version should not make any difference, that is only an update of the IDE. Are you using g++ as the compiler?... |
Forum: C++ Aug 26th, 2005 |
| Replies: 7 Views: 5,528 <<Moderator edit: Pointless flame-bait>> |
Forum: C++ Aug 26th, 2005 |
| Replies: 48 Views: 10,430 This thread started with a simple question:
How can one swap two numbers without a temporary variable?
One solution was the venerable xor way. Nobody advocated cleverness, speed, exclusivity,... |
Forum: C++ Aug 26th, 2005 |
| Replies: 48 Views: 10,430 Sorry, I meant DogTree, got him confused with TreeDog at the old Rock Bottom Brewery. Too much alcohol at times, a curse. |
Forum: C++ Aug 26th, 2005 |
| Replies: 48 Views: 10,430 x == y works just swell, maybe just for the moment. I am trusting programmers like Treedog and so on they have the experience. So, the SWAP macro has received the Oakwood Club flush!
In Reality 201... |
Forum: C++ Aug 26th, 2005 |
| Replies: 48 Views: 10,430 Thank you Junior Poster sara.rythm! Thank you for bringing up these question for the fun of it. As you can see, there are two kinds of people, the creative kind that get inspired by your puzzles,... |
Forum: C++ Aug 25th, 2005 |
| Replies: 48 Views: 10,430 That is most likely the reason 7 was picked as the multiplier. |
Forum: C++ Aug 25th, 2005 |
| Replies: 48 Views: 10,430 Now you got me started, for swapping either integers or floats this will work too ...
#include <iostream>
using namespace std;
int main()
{
int a = 1;
int b = 7; |
Forum: C++ Aug 25th, 2005 |
| Replies: 48 Views: 10,430 Ouch, I have forgotten how meticulous C is. Sorry, change the "of any type" to "integers only".
May I kindly suggest you start learning Python, then a simple ...
a, b = b, a
... will do. ... |
Forum: C++ Aug 25th, 2005 |
| Replies: 7 Views: 5,528 Do you want to do this in C or C++. For C++ see the code snippet at:
http://www.daniweb.com/code/snippet225.html
With C you have to slug it out in the trenches! Not too hard to do, just labor!... |
Forum: C++ Aug 25th, 2005 |
| Replies: 48 Views: 10,430 1. could be a trick question ...
std::cout << "numbers from 1 to 100 and 100 to 1";
2. assuming we are talking integers, use a macro like ...
// macro to swap two arguments of any type... |
Forum: C++ Mar 2nd, 2005 |
| Replies: 7 Views: 4,072 If your text file would look something like this
then you could read it into a list or array of structures with
the fields of Id Quiz1 Quiz2 Quiz3 Quiz4 Exam
using fscanf() or whatever ... |
Forum: C++ Mar 2nd, 2005 |
| Replies: 7 Views: 4,072 Take a look at:
http://www.daniweb.com/code/snippet139.html
It might just give you an idea. |
Forum: C++ Feb 5th, 2005 |
| Replies: 14 Views: 7,709 Test your program well. For instance put in 40 hours worked at 1 Dollar an hour, check the numbers. Put in 50 hours worked at 1 Dollar an hour. This should uncover a couple of minor mistakes. ... |
Forum: C++ Feb 4th, 2005 |
| Replies: 14 Views: 7,709 please use cin.get();
not
cin.gets();
my early morning booboo!
Also using if (doublevalue == 0) can give unwanted results since doubles notoriously approximate.
Make sure your totals... |
Forum: C++ Feb 4th, 2005 |
| Replies: 14 Views: 7,709 frrossk did a great job helping you! Please put the following lines near the end of your code, just above return 0; to make the console display wait:
cin.get(); // trap return
cin.get(); //... |
Forum: C++ Jan 16th, 2005 |
| Replies: 4 Views: 2,432 Are you sure you are running this project as a Windows Application? |
Forum: C++ Dec 28th, 2004 |
| Replies: 11 Views: 4,271 I am saying stdio.h, not cstdio, is in iostream in a convoluted way. Just bring it up in your editor and follow the yellow brick road through the includes. If you hum the tune along with the search... |
Forum: C++ Dec 28th, 2004 |
| Replies: 11 Views: 4,271 I got out the old Deitel from the college days and looked up the rules for a MACRO. Whatever it expands to, if it looks right it is right! No wonder the old prof hated them, it was a way the huns... |
Forum: C++ Dec 27th, 2004 |
| Replies: 11 Views: 4,271 This actually compiles and runs too. I can't tell you way.
Had to move the macro(?) out or get the same results as the originator.
// teasing Dev C++
#include <iostream>
#include <stdlib.h>... |
Forum: C++ Dec 27th, 2004 |
| Replies: 11 Views: 4,271 Why even bother with cin >> s ...
Is it April 1st? Or is this a submission to the Annals of Bad Programming? |
Forum: C++ Dec 18th, 2004 |
| Replies: 3 Views: 3,056 show_temps() does not walk through the list! |
Forum: C++ Dec 9th, 2004 |
| Replies: 2 Views: 3,164 In the 32 bit world integers have a range of:
-2,147,483,648 to 2,147,483,647 |
Forum: C++ Dec 6th, 2004 |
| Replies: 12 Views: 58,572 clrscr() is a presumptuous Borland fetish. Not every user of your program wants it!!!
In Dev C++ you can use system("CLS") to do the trick, the old DOS command. Include the stdlib.h for the... |
Forum: C++ Dec 3rd, 2004 |
| Replies: 17 Views: 24,829 I guess we can all google! Here is in interesting way for character permutations. Check the permutation after the original.
// This program finds permutations using a recursive method
//... |
Forum: C++ Dec 2nd, 2004 |
| Replies: 17 Views: 24,829 Actually, the algorithm for the next_permutation() is in the header file called stl_algo.h
Once you installed DevCpp this header file should be in
..\include\C++\3.3.1\bits\
Other compilers... |
Forum: C++ Dec 2nd, 2004 |
| Replies: 17 Views: 24,829 Any reasonably modern C++ compiler should give you access to the Standard Template Libraries!!!
If Borland Turbo C++ does not provide STL, you do yourself a favor by getting into a more updated... |
Forum: C++ Dec 2nd, 2004 |
| Replies: 17 Views: 24,829 The STL has a function next_permutation() which you can apply to a vector. This sample code is written for integers, it is your mission to apply your genius to make it work with characters! Report... |
Forum: C++ Oct 22nd, 2004 |
| Replies: 4 Views: 11,669 I don't have my Builder up anymore, but replace MB_OK with zero and see what happens. |