Forum: C++ Oct 30th, 2008 |
| Replies: 8 Views: 936 You could just have a pointer called "start" and when "current == start" you can set the input as you need. |
Forum: C++ Oct 29th, 2008 |
| Replies: 8 Views: 936 I don't think just L and R will cut it.
Lets say your maze is a rectangle that has n number of points, and there are walls inside it that construct a number of paths. Now the user needs to take... |
Forum: C++ Oct 21st, 2008 |
| Replies: 2 Views: 1,222 Well your variables below are local to the function. So when you leave the function, they don't exist and so their addresses now probably point to garbage values.
You should copy the values over... |
Forum: C++ Oct 21st, 2008 |
| Replies: 8 Views: 539 Its not deleting 3 numbers. Your for loop prints the numbers starting at index i instead of 0, so you "think" they are deleted.
You might want to delete the number and then call your print... |
Forum: C++ Oct 21st, 2008 |
| Replies: 8 Views: 539 are you sure it doesn't work ? it removes it correctly when I try using your code. |
Forum: C++ Oct 21st, 2008 |
| Replies: 8 Views: 539 You aren't assigning the variable index a value before calling the functions removeAt and insertAt. So you need to fix that first.
Well I just noticed that you are asking for the index in your... |
Forum: C++ Oct 18th, 2008 |
| Replies: 5 Views: 4,328 Here is a link that mentions how the fstream getline works Link (http://www.cplusplus.com/reference/iostream/istream/getline.html)
What you need to do is
SortedBinary.getline(myBuffer,... |
Forum: C++ Oct 18th, 2008 |
| Replies: 8 Views: 503 Add Code Tags Please !!!
And there is no #include<iostream.h>
its #include<iostream> |
Forum: C++ Oct 18th, 2008 |
| Replies: 12 Views: 1,304 One thing, which may or may not be a problem, is this
if (validAccount == false) {
.....
switch(AccountType) {
case 's':
case 'S':
....
validAccount = true; |
Forum: C++ Oct 17th, 2008 |
| Replies: 8 Views: 792 Visual C++ has deprecated most of the string functions, so you can add the define _CRT_SECURE_NO_WARNINGS to disable it or use strcat_s (but then the code will only compile with MSVC) |
Forum: C++ Oct 16th, 2008 |
| Replies: 8 Views: 792 Well if you cannot use string and have to use a char*, then you will need to use either strcpy or strcat or memcpy or memove .. |
Forum: C++ Oct 16th, 2008 |
| Replies: 8 Views: 792 Well you can define a variable of type "string" and then use += to add the words to it
for example:
string myString;
for (int i =0; i < maxwords; i++){
myString += randomwords[];
... |
Forum: C++ Oct 16th, 2008 |
| Replies: 4 Views: 323 You need to fix your main function. You are not passing in the correct arguments !
int main()
{
int User;
int Computer;
int choice; |
Forum: C++ Oct 15th, 2008 |
| Replies: 2 Views: 343 Please put code tags around your code.
Also, wouldn't it be easier to store the binary value you are computing in a string, inside your binary class ? And then just start at position starting... |
Forum: C++ Oct 14th, 2008 |
| Replies: 7 Views: 475 As far as I know these errors arise from the illegal quotes you were using. If you fix all of those, then it should compile correctly. Can you paste your Parse.cpp code if its not too long ? |
Forum: C++ Oct 14th, 2008 |
| Replies: 7 Views: 475 You have back-quotes ie ’\0’ which is different from using single quotes '/0' |
Forum: C++ Oct 14th, 2008 |
| Replies: 7 Views: 475 You're using the wrong quotes
const char opTable[] = {
'\0', '$', '(', ')', '^', '*', '/', '+', '-', '~' }; |
Forum: C++ Oct 14th, 2008 |
| Replies: 5 Views: 362 Well you need to pass number1 and number2 to your Plus function.
number and number2 are variables which are local to your main function, so Plus does not have access to them.
Try something... |
Forum: C++ Oct 13th, 2008 |
| Replies: 4 Views: 1,248 I get the same compile errors, and it goes into an infinite recursion. I think the problem is trying to pass in the dimensions where the compiler expects type specifiers ?
Perhaps an... |
Forum: C++ Oct 13th, 2008 |
| Replies: 4 Views: 1,062 To have separate constructors you will need to overload your constructor definition. You cannot have two constructions with the same prototype. One other reason to make your slist and dlist classes... |
Forum: C++ Oct 13th, 2008 |
| Replies: 6 Views: 493 In delete_node() you need to check whether your tree node "p" is NULL or not before proceeding to do the strcmp. Otherwise trying to access p->data will throw an exception. |
Forum: C++ Oct 13th, 2008 |
| Replies: 6 Views: 493 Its probably a segmentation fault of some sort. I cannot say what it is just glancing at your code. You may want to put some debug print statements or breakpoints in your code to try and narrow down... |
Forum: C++ Oct 13th, 2008 |
| Replies: 4 Views: 1,062 Something like this might work. But I think you would be better off defining your nodes as classes instead of structures. It will give you encapsulation for your data.
template <class T>... |
Forum: C++ Oct 13th, 2008 |
| Replies: 6 Views: 493 Take a look a this function
struct tree_node * edit_node (struct tree_node *p, char l[], char f[]) {
The prototype suggests that your edit_node should return a value of type struct... |
Forum: C++ Oct 13th, 2008 |
| Replies: 8 Views: 572 Are you familiar with vectors ? If so you can use a 2 dimensional vector and that way you wouldn't have to mess with the memory allocation yourself.
here... |
Forum: C++ Oct 9th, 2008 |
| Replies: 4 Views: 519 You have to be a little more careful, but this is how you can do it.
int main()
{
int rows, cols;
int **pointer;
cout<<"Enter rows and columns for your 2-D array\n";
cin >> rows >>... |
Forum: C++ Oct 9th, 2008 |
| Replies: 3 Views: 393 cin as you know will read your input variables separated by spaces. There no way to get cin to do what you want.
You can use getline or you can overload the istream operator and write your own... |
Forum: C++ Oct 9th, 2008 |
| Replies: 7 Views: 545 You can use the while loop you have, intialize x to 1 before the loop and increment x each time in the loop.
Another option is using a for loop
for (int i = 1; i <= 5; i++){
// compute... |
Forum: C++ Oct 9th, 2008 |
| Replies: 8 Views: 584 I am not really sure what the OP wants to do either .. :) , sometimes I end up suggesting things they haven't heard of yet ! |
Forum: C++ Oct 9th, 2008 |
| Replies: 8 Views: 584 I don't see you printing the spaces anywhere ? You can use "setw()" and "right" to set a width and then align your output to the right. |
Forum: C++ Oct 8th, 2008 |
| Replies: 10 Views: 1,109 Lets try some pseudocode here. Your terminating condition should be size == 0, because the array elements go from 0 to size - 1;
max (arrayNumbers, arraySize){
if (arraySize == 0)
... |
Forum: C++ Oct 8th, 2008 |
| Replies: 5 Views: 788 ok I am not sure what your itemType is so lets assume its a basic data type like int or string and your file has those in it.
so
itemType element;
ifstream InData;
InData.open... |
Forum: C++ Oct 8th, 2008 |
| Replies: 5 Views: 788 why are you passing an argument of type ifstream to List.insert() when it obviously expects an argument of the type "itemType" ?
I understand you have your items in a file, but do you expect the... |
Forum: C++ Oct 8th, 2008 |
| Replies: 5 Views: 788 Your else is outside your while loop .. it might help to format your code more cleanly
while (location != NULL){
if (item == listPtr->item ){
return true;
}
} // while ends
//... |
Forum: C++ Oct 8th, 2008 |
| Replies: 10 Views: 1,109 Are your numbers sorted in the descending order ? Because otherwise when you do
if (first > next) return first;
it will always return the larger of the two numbers : test case 2, 1, 3, 4, 5, will... |
Forum: C++ Oct 8th, 2008 |
| Replies: 8 Views: 649 You can also use lexicographical_compare (http://www.cplusplus.com/reference/algorithm/lexicographical_compare.html) |
Forum: C++ Oct 7th, 2008 |
| Replies: 4 Views: 444 These lines here
_cptPoints = new CPt [++_iSize];
_cptPoints = Tmp;
You allocate space for _cptPoints, and then you assign it to Tmp, which means you've now lost the memory pointer... |
Forum: C++ Oct 7th, 2008 |
| Replies: 18 Views: 1,314 This is not valid code. The result of the && operation is a boolean value and you cannot equate that to a string.
if(info == (EmployeeInfo[cntr].get_first_name() &&
... |
Forum: C++ Oct 7th, 2008 |
| Replies: 18 Views: 1,314 You shouldn't have to pass anything to display_info(). Since its a class member function it already has access to the data members for that object.
So you can either break out of the for loop... |
Forum: C++ Oct 6th, 2008 |
| Replies: 18 Views: 1,314 Well if you have a person class, then it can have your get or accessor functions.
for example:
class People{
public:
getFirstName();
.......
private:
string firstname; |