Forum: C++ Dec 29th, 2008 |
| Replies: 12 Views: 633 int &x = *new int();
This should do it. |
Forum: C++ Dec 12th, 2008 |
| Replies: 5 Views: 942 |
Forum: C++ Dec 12th, 2008 |
| Replies: 14 Views: 2,576 that should be cin >> word;, because word[i] is a char, and word is a char array
Likewise this should be ...
if(string(text).find(word) != string::npos){
..., otherwise you are comparing the... |
Forum: C++ Dec 12th, 2008 |
| Replies: 10 Views: 898 I have an dumb idea, what about an operation like convolving the test string with itself; i.e. doing a sliding comparision of the elements of the test string with the reversed-test-string. The... |
Forum: C++ Dec 10th, 2008 |
| Replies: 4 Views: 399 or you could make a card class, e.g.
#include <iostream>
#include <string>
using namespace std;
class Card{
private:
int cardNumber; // 1 - 52
public:
Card(int _cardNumber =... |
Forum: C++ Nov 29th, 2008 |
| Replies: 3 Views: 438 assuming str is of type 'string', str[i] is of type 'char'. chars will be considered negative whenever the top bit is set. It's not an issue if you are bitwise ORing, as you will get the correct... |
Forum: C++ Nov 28th, 2008 |
| Replies: 1 Views: 292 sprintf expects a char* as the first parameter; it is where it will store the output, as a string of characters.
I don't know what you actually want to do, but if you want to see that it's... |
Forum: C++ Nov 23rd, 2008 |
| Replies: 2 Views: 336 Have you tried compiling it? |
Forum: C++ Nov 23rd, 2008 |
| Replies: 10 Views: 1,227 then start at a value 1 more than the highest in the dB, if you wish to use incrementing type indexes. Or you could use the number of microseconds since (e.g.) 12:00am jan 1900 UTC as your 'unique... |
Forum: C++ Nov 22nd, 2008 |
| Replies: 5 Views: 428 Not quite. Distance of 1 from (0,0) heading 45^ will be (0.707, 0.707)
Where did you get this formulae? Travelled distance is not proportional to heading. try dx = distance * cos(heading / 180.... |
Forum: C++ Nov 18th, 2008 |
| Replies: 1 Views: 1,307 OK, I found out the compilation option -mthreads (MinGW specific) is needed to allow safe threaded code with exceptions. It may also be the case that -pthreads is required for non-MinGW gcc. |
Forum: C++ Nov 17th, 2008 |
| Replies: 1 Views: 1,307 Hi. I have written a small test socket program that uses a background thread that accepts tcp connections and adds them to a connection list that is accessed by main().
When a connection is... |
Forum: C++ Nov 15th, 2008 |
| Replies: 5 Views: 909 not so friendly hey?
So what do you actually want? The length of the string at compile time?
#define _MyMacro(cstr) cstr, sizeof(cstr)
Should work if your string constructor accepts (const... |
Forum: C++ Nov 14th, 2008 |
| Replies: 18 Views: 2,480 For hi-res timers, you may want to have a look at the following (100us timer period):
http://www.codeproject.com/KB/system/RealTimeModule.aspx
What's the frequency of the PWM? Are you... |
Forum: C++ Nov 9th, 2008 |
| Replies: 6 Views: 843 ummm....
google seems to quickly turn up a bunch of results for this question, e.g. http://www.cppreference.com/wiki/operator_precedence
You're right, division/multiplication/modulus all have... |
Forum: C++ Nov 9th, 2008 |
| Replies: 10 Views: 697 A byte is made up of 8 bits. Therefore a row can contain the 16 bits in 2 bytes. There are 16 rows, hence 2 x 16 bytes.
Calculate 16 x 16 bits = (2 x 8) x 16 bits = 256 bits. |
Forum: C++ Nov 8th, 2008 |
| Replies: 2 Views: 1,372 include the dll.h header, and not the project3.dll file.
Make an import library - the .lib file, should be an option in your compiler/linker
link the .lib file into your project. The program... |
Forum: C++ Nov 6th, 2008 |
| Replies: 2 Views: 1,435 I wrote an equation parser a few years back, don't have it on me, but I'll try to dig it up for you.
I think the idea I used was to pass through the equation string a few times - the first time... |
Forum: C++ Nov 4th, 2008 |
| Replies: 10 Views: 3,433 As ArkM stated, you don't need to return an integer value as a complex<double> (although you can if it pleases you, of course).
I found the condition in the while() loop a little strange, so I... |
Forum: C++ Nov 4th, 2008 |
| Replies: 4 Views: 429 Dunno from the code you posted. Was the data even written properly in the first place? Did you open the fstream in binary mode? |
Forum: C++ Nov 4th, 2008 |
| Replies: 6 Views: 3,112 If you're just displaying the reversed thing to the screen, there is no need to store any numbers in any arrays.
Each call to the function will print out a single digit (the digit of number in the... |
Forum: C++ Nov 4th, 2008 |
| Replies: 1 Views: 680 yes. You'll be using travel ** travelArray
That said, your assignment line will of course be travelArray[index] = &aTrip;
I noticed you check if index <= size. If the array declared has size... |
Forum: C++ Oct 11th, 2008 |
| Replies: 6 Views: 516 Most of your code (not the above function) looks good. The statement fib(0) = sizeCrudPopulation; is not valid as fib() is a call to a function. You could use an array and then use fibarr[iter] =... |
Forum: C++ Oct 11th, 2008 |
| Replies: 8 Views: 622 Line 20 should be moved to after line 24: you want to let the user enter the search value before you call the search function.
line 86: remove this line - the break statement would quit the loop;... |
Forum: C++ Oct 11th, 2008 |
| Replies: 8 Views: 667 This thread seems to be predecessor to http://www.daniweb.com/forums/thread150474.html |
Forum: C++ Oct 11th, 2008 |
| Replies: 2 Views: 357 setw works fine without the need for '\t'. Note that setw is required prior to each item to be formatted.
e.g. cout << left << setw(12) << "item1" << setw(12) << "item2" << endl; |
Forum: C++ Oct 10th, 2008 |
| Replies: 5 Views: 556 What
That line should be if (test == '1')
1 is different to '1' (character code 49, as Rhohitman said). Also, for powers of 2 you don't have to use pow(). Using the shift... |
Forum: C++ Oct 10th, 2008 |
| Replies: 12 Views: 2,406 I don't think it's in the language.
You could use #define square box.
You may want to google template typedefs, or check out http://www.gotw.ca/gotw/079.htm for some solutions. |
Forum: C++ Oct 7th, 2008 |
| Replies: 3 Views: 1,639 How about you use code tags and post code that can be compiled.
There are easier ways to get file listings by using the OS list functions & _popen(). The output can be read using fread(). In... |
Forum: C++ Oct 5th, 2008 |
| Replies: 28 Views: 2,740 What?? I know a lot of people who will write code for money (myself included). I believe it's fairly standard practice; even a respectable career option. |
Forum: C++ Oct 5th, 2008 |
| Replies: 2 Views: 408 Windows CE has APIs for this kind of thing. The prototype for the function is BOOL CopyFile(LPCTSTR lpExistingFileName, LPCTSTR lpNewFileName, BOOL bFailIfExists); .
Go to MSDN if you need info... |
Forum: C++ Oct 3rd, 2008 |
| Replies: 6 Views: 1,479 You would only scan to the left if a more-right digit couldn't be incremented - in which case you would try to increment a digit to the left. When you find a digit that can be incremented, you would... |
Forum: C++ Oct 3rd, 2008 |
| Replies: 6 Views: 1,479 Obviously recursion would enable a simpler/cleaner approach, if it were allowed.
There is no mention of need for speed/efficiency in the problem statement, so it may be perfectly valid to just use... |
Forum: C++ Oct 3rd, 2008 |
| Replies: 2 Views: 486 Do you not know how to use google (or any other search engine)? You will find more than you need if you actually try looking for it.
Try http://en.wikipedia.org/wiki/Global_variable |
Forum: C++ Oct 3rd, 2008 |
| Replies: 5 Views: 2,654 I'm pretty sure there's oodles of freely available guides available to tell you how to use openCV. Try http://www.google.com/search?hl=en&rls=com.microsoft%3Aen-au&q=opencv+visual-studio
Failing... |
Forum: C++ Sep 30th, 2008 |
| Replies: 3 Views: 1,634 OK. The following is how I might do it:
you can still use getline(cin, inputLine); which means you won't have to type in FINISHED, just the enter key.
inputLine will now contain all the words... |
Forum: C++ Sep 30th, 2008 |
| Replies: 5 Views: 731 1) I didn't say get rid of them, just that they are declared and you're not using them - maybe you should.
2) due to the first if statement always running the line: count(valueRow, valueCol + 1,... |
Forum: C++ Sep 30th, 2008 |
| Replies: 3 Views: 1,634 use getline to read the inputSentence from cin. This will stop reading when it gets the enter key.
put the entered sentence into a stringstream.
read the words out of the stringstream while... |
Forum: C++ Sep 30th, 2008 |
| Replies: 5 Views: 731 The count method is incorrect; there is no terminating condition, hence the stack overflow.
(map[valueRow][valueCol + 1] != 'b' || map[valueRow][valueCol + 1] != 'v') will always be true, as the... |
Forum: C++ Sep 30th, 2008 |
| Replies: 6 Views: 1,389 I can't see any reason why you don't just split all the fields, assign:
field[] = split(line, " ")
genre = field[0]
category = field[1]
title = field[2]
n = field.count()-1
for i = 3 to... |