Forum: C++ Dec 29th, 2008 |
| Replies: 12 Views: 636 int &x = *new int();
This should do it. |
Forum: C++ Oct 11th, 2008 |
| Replies: 2 Views: 359 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 5th, 2008 |
| Replies: 2 Views: 411 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++ Sep 22nd, 2008 |
| Replies: 9 Views: 595 for(int i = 0; i < ARRAY_SIZE; i++){
int j = rand() % ARRAY_SIZE;
if(i != j)
swap(array[i], array[j]);
} |
Forum: C++ Sep 14th, 2008 |
| Replies: 12 Views: 808 Oh don't give up now; you look like you're really close. I'd say there's plenty more weedy students in your class than you.
A lot of the compiler errors are duplicate function definition: it means... |
Forum: C++ Sep 8th, 2008 |
| Replies: 4 Views: 941 I tried your program, seemed to run in dev-c++ & visual-c++2008 (with the reported error). Tried debugging it, saw that the stack pointer certainly is different before call to after call (that's bad)... |
Forum: C++ Apr 17th, 2008 |
| Replies: 8 Views: 858 That should have been x = y. The complexity of the statement must have confounded me.. |
Forum: C++ Apr 13th, 2008 |
| Replies: 2 Views: 459 put the srand(time(NULL)); in the main(), such that it is run only once.
As you have it, every time RandomNumber() is called, srand() is seeded with the same value - hence rand() returns the same... |
Forum: C++ Apr 11th, 2008 |
| Replies: 6 Views: 2,675 To check if an iterator has passed over all elements compare it to the end (for iterators) or rend (for reverse iterators).
string::reverse_iterator rit = st.rbegin();
string::iterator it... |
Forum: C++ Apr 10th, 2008 |
| Replies: 9 Views: 1,808 Why don't you try running the program and pressing the enter key. The program will display the code for the key. Then you can put the key code as a case in the switch() just like what has been done... |
Forum: C++ Apr 5th, 2008 |
| Replies: 7 Views: 930 As AncientDragon said, CreateThread() can be used in windows. Check it out on MSDN. Following is some code to show you how to use it. Note that the thread proc should be of the form DWORD WINAPI... |
Forum: C++ Mar 29th, 2008 |
| Replies: 2 Views: 679 Also won't always give a number in the range of min...max. You may want to consider using r = (rand() % (max - min + 1)) + min; |
Forum: C++ Mar 27th, 2008 |
| Replies: 21 Views: 2,496 |
Forum: C++ Feb 19th, 2008 |
| Replies: 5 Views: 596 Hey, Why are you closing the input file inside the loop (line 68)?? surely you want to read all the data before closing the file! |
Forum: C++ Jun 28th, 2007 |
| Replies: 18 Views: 7,563 Hinduengg,
Insertion sorting is simply inserting each of the unsorted values into the list of sorted values in the location that keeps the list of sorted values correctly sorted. e.g. to sort in... |