Forum: C++ 10 Hours Ago |
| Replies: 3 Views: 109 You have to redeclare a size for length other than zero every time through the for loop as it goes to zero in the while loop. |
Forum: C++ 11 Hours Ago |
| Replies: 3 Views: 106 Now convert it to do this:
Use a single-subscripted array to solve the following problem.
The array should be used instead of all the individual counters. Each array element will represent one... |
Forum: C++ 13 Hours Ago |
| Replies: 2 Views: 96 NumGames needs to be in scope in order for this to work, too.
Also, this:
Games[i].GetHomeScore
suggests an accessor function for a member variable of the object Games[i] called Home Score... |
Forum: C++ 13 Hours Ago |
| Replies: 6 Views: 145 As long as it is declared before it is called and is defined somewhere the compiler/linker can find it, go ahead. |
Forum: C++ 1 Day Ago |
| Replies: 9 Views: 165 Duh, my bad. If a unique string is identified then numUnique needs to be increased in addition to the unique string being entered into uniqueStrings. In post #4, between line 17 and 19 put a line... |
Forum: C++ 1 Day Ago |
| Replies: 9 Views: 165 Line 32 shouldn't use 10 as the terminating value of the loop as uniqueString could have a single unique string if all inputs are the same, 10 uniques strings if inputs are all different, or... |
Forum: C++ 1 Day Ago |
| Replies: 2 Views: 102 What type of array to you think fMatr is? Or putting it another way, is fMatr declared as a single dimensional array or a two dimensional array? |
Forum: C++ 1 Day Ago |
| Replies: 9 Views: 165 Post code used to display uniqueString[] and indicate if the code is in main() or in a function. Also, where is uinqueString[] declared relative to it's being displayed----same or different... |
Forum: C++ 1 Day Ago |
| Replies: 19 Views: 374 in function prototypes you don't need to name the variables acting as arguments/parameters. In function definitions you have to name the argument/parameter being passed in addition to it's type. |
Forum: C++ 1 Day Ago |
| Replies: 2 Views: 124 Delete lines 16, 17 and 18.
Delete everything to to the right = signs in the equations in lines 20, 21, 22 and put the = sign in the string identifying the operation that is being done.
... |
Forum: C++ 1 Day Ago |
| Replies: 9 Views: 227 36 no matching function for call to `toupper(std::string&)'
The above means that the toupper() doesn't take a std::string (also known as an STL string object). toupper() takes a single char. ... |
Forum: C++ 1 Day Ago |
| Replies: 9 Views: 165 int counter[10] = 0; //initialize all counters to zero
int numUnique = 0; //to keep track of unique strings found so far
int arrayCell; //declare outside loops to keep in scope throughout loops... |
Forum: C++ 2 Days Ago |
| Replies: 19 Views: 374 What happens if you flip right and left of the = operator in line 57 around? |
Forum: C++ 2 Days Ago |
| Replies: 9 Views: 227 Line 11 is just plain weird. It has two types followed by a function name and parameter list. I thing what you did was declare main() as type void on line 11 initially with a function prototype for... |
Forum: C++ 2 Days Ago |
| Replies: 3 Views: 165 Do you mean something like this:
double temp;
char space = ' ';
//process stack until only one operand remains in stack
while(operands.size() > 1)
{
//get first two operands off... |
Forum: C++ 3 Days Ago |
| Replies: 3 Views: 165 All you want on line 32 is the command from the user.
To look a little further, how are you going to know how many operands remain on the stack and whether it's valid to call another command. ... |
Forum: C++ 3 Days Ago |
| Replies: 2 Views: 135 Since you don't know how many salesmen or how many sales there will be you are probably better off using a list or a vector (if you know about these containers) because they enlarge as needed, rather... |
Forum: C++ 3 Days Ago |
| Replies: 3 Views: 138 Set part 2 and 3 aside.
Did you try putting step 1 in a program to see if it compiled/worked?
Why would your instructor tell you to pass length to the function if they didn't want you to... |
Forum: C++ 3 Days Ago |
| Replies: 7 Views: 206 First things first. Even if your code doesn't explicitly need it you should (almost) always have a default constructor in addition to any non-default constructors in your class. If you don't know... |
Forum: C++ 3 Days Ago |
| Replies: 5 Views: 204 Now it looks like a cut and paste disaster. Scrap the last post and go back to your first post. Then using post #1 try fixing one error at a time as suggested in post #s 2 and 3. (Better yet, in... |
Forum: C++ 3 Days Ago |
| Replies: 3 Views: 138 Don't think too much about parts 2 and 3 when working on part 1. The instructor has it set up so if you can do earlier parts as instucted it they will flow nicely into latter parts. Once you have... |
Forum: C++ 3 Days Ago |
| Replies: 5 Views: 150 If you know about boolean types you could consider returning a boolean variable instead of a string variable. At least that's the type I think of when I want/need to return true/false. |
Forum: C++ 3 Days Ago |
| Replies: 5 Views: 199 Start with task #1. When you can do that then try doing task #2. When you can do that then try #3. Don't think of the whole program all at once. Once you have both matrixes, then the code to set... |
Forum: C++ 3 Days Ago |
| Replies: 7 Views: 246 There is no routine way to print a variables name. You could create a user defined type and include the name of the type as one of the data members. However, the name of the variable itself, not... |
Forum: C++ 4 Days Ago |
| Replies: 5 Views: 216 You didn't call binarySearch() in post #1 so it wasn't needed. I just assumed you didn't post showArray() because it wasn't pertinent. I just added a definition for showArray() with empty function... |
Forum: C++ 4 Days Ago |
| Replies: 7 Views: 246 Some information on both is available at cppreference.com, but having your own reliable hard copy reference book would be strongly recommended, too. |
Forum: C++ 4 Days Ago |
| Replies: 7 Views: 246 you should be able to use the substr() method to isolate the last two char of the string and you should be able to use a stringstream to convert the string isolated by substr() to an int. Both... |
Forum: C++ 4 Days Ago |
| Replies: 5 Views: 216 my bad, I didn't see the 1 at the end of fileName1 which is why I don't even like to use long file names that differ by just a single value because I get them mixed up when scanning code.
I did... |
Forum: C++ 4 Days Ago |
| Replies: 5 Views: 214 What is sizeof(e) anyway given that name can have any size up to 79? If you wanted to use write() I would recommend using two separate calls, one using strlen(eArray[counter].name) as the second... |
Forum: C++ 4 Days Ago |
| Replies: 7 Views: 246 Isolate (using whatever method you like) the last two char of each string as a substring and then convert the substring to an int (using whichever method you prefer). There are at least two ways to... |
Forum: C++ 4 Days Ago |
| Replies: 5 Views: 216 You have two variables with the same name, fileName, which may well be problematic, but I see only two calls to selection sort, neither of which have the 4th parameter as an array and the types... |
Forum: C++ 4 Days Ago |
| Replies: 3 Views: 164 I'd change the single | to a double ||.
The ostream method write() takes two parameters and I find it difficult to see how the return type of DrawBoard(), whatever that is, can provide both... |
Forum: C++ 4 Days Ago |
| Replies: 1 Views: 140 Googling leads me to believe that an adjacency matrix of a graph is an n by n matrix where n is the number of vertexes represented in the graph. The rows represent which vertex you are starting... |
Forum: C++ 5 Days Ago |
| Replies: 6 Views: 287 I'm glad you've been able to work out a solution to the problem you encountered, though I don't think it is because of the reason you think. Look at my code below to find out how to prove or... |
Forum: C++ 5 Days Ago |
| Replies: 4 Views: 186 If you are trying to write code for a tree then I assume you are familiar with writing code for a list. You can think of a list as a tree that has only 1 child per node and they all rights or lefts... |
Forum: C++ 5 Days Ago |
| Replies: 13 Views: 338 guccitan88: Using code in post #11:
1) Move line 9 to line 18. Reason: don't use global variables unless you have to. If you feel you must use array a as a global variable then don't pass it to... |
Forum: C++ 5 Days Ago |
| Replies: 3 Views: 169 Frist, main() should return type int, not type void. Even if your compiler allows you do use reurn type void, don't do it.
The problem you allude to however, probably has to do with line 118. If... |
Forum: C++ 5 Days Ago |
| Replies: 5 Views: 202 To my knowledge, only if wheels is a member variable declared with keyword const. That is, it is the declaraion the member variable called wheels as const that prevents it from being changed somehow... |
Forum: C++ 5 Days Ago |
| Replies: 4 Views: 150 comment out lines 26 through 53, recompile and rerun. The } on line 18 ends main().
My post was an effort to use your code as the basis for an example of writing and calling functions. I... |
Forum: C++ 5 Days Ago |
| Replies: 6 Views: 287 As jonsca said, any newline char in the file opened by the stream called plainText will be eliminated from the stream by getline() as it is the default delimiting char for getline() and getline()... |