1,608 Posted Topics

Member Avatar for infern0

I assume food and calories are parallel arrays meaning that food[x] has calories[x] calories and you want to keep the food matched with the correct calories and you are trying to alphabetize the food array. If that is the case then swap calories[x] and calories[x + 1} in the body …

Member Avatar for infern0
0
110
Member Avatar for matmeister

Between line 42 and 43 put a check statement to confirm appropriate read from file. Maybe something like: cout << "file read is: " << sentence << endl; In isPalindrome() strip the punctuation and spaces from temp before testing. Don't just advance indexes. Use i to be the letter in …

Member Avatar for zobadof
1
334
Member Avatar for digital_ice7
Member Avatar for mrnutty
0
94
Member Avatar for noofin

The best solution would be store the input in an STL string object. If you aren't familiar with them, then you could use a null terminated char array to store the same information. string stlString; //include the string header file to do this type const int MAXSIZE = 1086; char …

Member Avatar for Bench
0
93
Member Avatar for Towely

Um, have you had practice dealing with user defined types such as classes or structs. If so, I suspect he wants to de declare a type called Fractions and do whatever you have to do be able to add two objects of type Fraction together using a function with the …

Member Avatar for rbrt13
0
1K
Member Avatar for confusedndazed
Member Avatar for confusedndazed
0
116
Member Avatar for merse

To my knowledge the memory requirements for an object of the class requires memory for the member variables plus memory for a pointer (the this pointer). No memory is required for member functions or friend functions, etc of an object. Member functions are kept in the class declaration/definition. Ideally the …

Member Avatar for merse
0
170
Member Avatar for aq5

C++ knows nothing about color. You will need graphics program of some sort in addition to the C++ code to change the color. You can probably do this through Windows API using Console functions, but you could surely do it with a full fledged graphics program. If you aren't learning …

Member Avatar for Murtan
0
459
Member Avatar for theeurostick

First: welcome to the board. Second: when posting code use code tags. Instructions on how to use them are embedded in the watermark of the Message box used to post your thread as well as in the announcement section at the top of the board. Third:The easier you make it …

Member Avatar for Lerner
0
295
Member Avatar for merse

given valid object x of type X: X x; if prototype is void foo(X&); and function call is foo(x); //compiler automatically converts x from type X to X& if prototype is void bar(X*); and function call is bar(x); //no automatic conversion of x from type X to type X* by …

Member Avatar for Narue
0
115
Member Avatar for vinsbg

Please clarify. If list starts with 1->10 and you want to add 5 to the list do you want to end up with 1->5->10 or 1->10->5? If 5 already exists in the list do want to allow a second 5 in the list or ignore it if it comes up …

Member Avatar for vinsbg
0
101
Member Avatar for Valaraukar

The most obvious possibility, but maybe the least likely, is that the prototype withdraw() post #3 line 1 and function call to withdraw, post #4 line 54 do not match with regard to number of parameters. I suspect however that this is a "posting/typo" error and probably not what the …

Member Avatar for Valaraukar
0
183
Member Avatar for sreejithbabu

When mixing getline() and >> in the same program you have to account for the fact that >> leaves the terminating whitespace (new line char usually) in the input buffer. Then when getline() comes around after a call to >> it finds the terminating char to the previous >>, newline, …

Member Avatar for sreejithbabu
-1
888
Member Avatar for Valaraukar

You might want to look into Run-Time Type Identification (RTTI). I got some pretty good hits searching RTTI on Google. A good reference book is hard to beat though. You might be able to get by with embedding the type of the object within the object so that you can …

Member Avatar for GrubSchumi
0
134
Member Avatar for HelloMe

Fucntion calls should not be preceded by the return type. So, from line 99 to 131 remove all the return type designations. Learning when to use semi-colons takes a little practice. You should put a semicolon after the closing parenthesis of function calls unless there is a good reason not …

Member Avatar for HelloMe
0
79
Member Avatar for Afupi

A stack sounds like a good idea and your explanation is rational. To make it a little easier to understand start with a simpler maze. Consider a simple maze that has just 3 cells in the shape of an L with the start at the top of the L and …

Member Avatar for Afupi
0
227
Member Avatar for SurviBee

Debug it by throwing a bunch of output statements in the code to see where it deviates from what you expect or use the debugger that probably came with your compiler to monitor variable values as you step through the code.

Member Avatar for sweetkim_2008
0
203
Member Avatar for Jalwes

When input methods like getline() or >> fail the return value equates to false which then prevents the loop from proceeding. Finding the end of file (EOF) is one of the conditions that causes the streams to go into a failed state, so the input will stop. (Note: If you …

Member Avatar for Lerner
0
98
Member Avatar for johndory

This polynomial: 3x^2 + 5x + 1 could also be written like this: 3x^2 + 5x^1 + 1x^0. This suggests that the polynomial could written as a series of terms with 3x^2, 5x^1, and 1x^0 each being one term. Each term would have a coefficient, a variable (which must the …

Member Avatar for fireprogramer
0
4K
Member Avatar for johnray31

It looks as though you are using the node * called head to be the first node in the list. Once there is an actual node associated with the pointer you don't want to change it, unless you want to make a new head node. The reason to point this …

Member Avatar for vibhu1
0
233
Member Avatar for jlouang

Just embed the switch statement to activate the menu choice within a do/while loop as indicated in the instruction [code] do { //display menu switch(choice) { case 1: //use for loop break case 2: //use while loop break case 3: //use do/while loop break case 6: //exit default //output information …

Member Avatar for IT seeker
0
173
Member Avatar for mevkurray

Are you wedded to using strtok()? If not, use the '`' char as the delimeter of the parsing phase, whether the parsing is done initially or after first line read. [code] while(read in first line) { parse first token of first line if(first token == some arbitrary token) parse rest …

Member Avatar for mevkurray
1
1K
Member Avatar for nightninja12

Not a traversal function. You want to be able to traverse without needing to write to file each time you do a traverse. A separate save function is probably best. That gives you more control. In addition it allows you to save the entire tree or any subtree of the …

Member Avatar for Lerner
0
161
Member Avatar for reese27

In the example shown I'd probably use the appropriate version of getline() for the type of string I'm going to use with the comma char as the delimiting char. This could be generalized to using any valid char as a delimiting char, not just the comma char. However, if the …

Member Avatar for Lerner
0
115
Member Avatar for aikawa

To store that type of information in an array I would use a 2D array of char. I would read in one char at a time, using a nested for loop where the outer loop controlled which row I was in and the inner loop controlled which column I was …

Member Avatar for ankitnigam
0
507
Member Avatar for osgiedeprof

You use the STL string class later in your program so why not use it here, too: string Dictionary[12][2] ={ {"God", "osalobua"}, etc and here: string word; Line 35 could then be: for(i = 0; i < 12; ++i) and Line 36 is simply if(word == Dictionary[i][0]) with line 41 …

Member Avatar for Lerner
0
167
Member Avatar for ninreznorgirl2

purposely over commented code for beginner to understand process[code] //declare a flag variable bool invalidInput; //outer loop controls number of digits input while(k < MAX_DIGITS) { //reset flag each time through outer loop invalidInput = true; //inner loop while(invalidInput) { //gets char input cin.get(ch); //validates char input if(!isalpha(ch)) //could use …

Member Avatar for Lerner
0
135
Member Avatar for chubzyko

Do you know how many items or a maximum number of items there are in the file? If not an array probably isn't the best container to hold the data, unless that it is the container type you are required to use. Do you know about classes and structs, because …

Member Avatar for Lerner
0
2K
Member Avatar for amroto

I'd do it something like this: [code] oper = '@'; cout << " enter first operand: " << '\n'; cin >> op1; while (op != '~') { cout << "\nEnter operator: " ; cout << "enter the tilde sign ('~') to stop" << '\n'; cin >> oper; if(oper != '~') …

Member Avatar for gbantsi_2
0
130
Member Avatar for raigs

"Content-length: " That is a string and this: BUFFER.length() equates to an int. So when you use the + operator between the two are you trying to concatenate an int onto the string or are you trying to add an int to a string or are what are you trying …

Member Avatar for raigs
0
147
Member Avatar for Your_mum

Pointers are useful for a variety of reasons. For, example, let's say I want to pass the value of my salary from one function to another. The value of my salary will be changed in the function it is passed to and I want to use that new value in …

Member Avatar for Your_mum
0
102
Member Avatar for peekamalts

The microwave is nothing but an oversized paperweight unless you have a series of what to tell the microwave what you want it to do? I'd consider these things "Top-Level Objects" since nothing gets done without them, but then I'm not in your class so I don't know how your …

Member Avatar for jasvir
-1
334
Member Avatar for kekz0r

If you know the first key then maybe something like this will work. Encrypt: while there are letters to encrypt generate random letters until current key is generated place a letter of message generate random letter to act as next key repeat Decrypt---need to know first key while no further …

Member Avatar for kekz0r
0
209
Member Avatar for Cy137

Be more descriptive of the problem and you are more likely to get an answer. Not everyone is going to download, compile, run, analyze and then post a response. After quickly reading through posted code in getData() i would change this:[code] while(!openFile.eof()) { openFile >> temp;[/code] to this:[code] while(openFile>>temp) {[/code] …

Member Avatar for vmanes
0
134
Member Avatar for ninreznorgirl2

No need for AssignValue to be a friend function unless it is a requirement of the assignment. How will AssignValue know how many digits to place before and after the decimal point? 123.456 0.123456 and 123456.0 are all valid float/doubles variables. Passing both values to the function would be one …

Member Avatar for Lerner
0
212
Member Avatar for RohitSahni

There is no way to do this in standard C++. There are non-standard ways to get the job done, some of which are in common use, though. Knowing at least some of the information asked by Duoas will be necessary to try to help inform you of which non-standard methods …

Member Avatar for shashanderson
0
241
Member Avatar for countrygirl1970

Focus your code posting to just the pertinent part. sometimes it's hard to know where that is, but in your case it shouldn't be. Sounds like a do/while loop using something like isdigit() might work if the numerical input is from 0-9. Otherwise you could check the state of the …

Member Avatar for countrygirl1970
0
188
Member Avatar for Damirz

To my knowledge you can't initialize just a portion of the elements in an array, it's all or none. You can use a loop to assign a desired value to a portion of an array. That's what I would encourage you to do.

Member Avatar for mrnutty
0
271
Member Avatar for MeBjess

If you want lines 45-48 to run only in association with the last else if, then they should be enclosed in a code block using curly brackets. Probably a better thing, however, would be to output statement to user that the selection entered is invalid and they should try again. …

Member Avatar for MeBjess
1
117
Member Avatar for ross42111

Where do you give num and num1 a value before you pass it to either the recursive or the iterative process? Shouldn't line 22 and 23 be between line 28 and 29? Expand line 46 to three lines: double temp = fnum * wk7recur(fnum,inum -1); cout << temp << endl; …

Member Avatar for Lerner
0
148
Member Avatar for surfer2009

Please learn how to use code tags when posting code to this board. It is a bit of a hassle, but given it preserves the spacing you (should be) use in writing the code it is well worth it. There are multiple locations on the board where you can learn …

Member Avatar for mrnutty
0
106
Member Avatar for koban_alche

Don't use postfix both hold the expression and act as a stack to evaluate the expression. I would suggest declaring an array of type double called myStack to use in evaluating the expression. The elements of postfix are all type char. Since the compiler recognizes type char by the integer …

Member Avatar for dkalita
0
113
Member Avatar for lancevo3

I recommend you think twice about simple copying of head and tail pointers to copy one list to another. This is called shallow copy and works okay in simple programs but it can quickly cause problems if you aren't aware of what is happening. In particular, under this scenario if …

Member Avatar for native
0
512
Member Avatar for robgeek

In this specific case you could use two loops. One to get the number of elements indicated by length %2 and the other to however many groups of length/2 elements there are.

Member Avatar for Lerner
0
97
Member Avatar for C++NOOOB

have you tried syntax similar to this: MyObject.bvec[n]; It should work as long as n is less than the size of bvec, which in the code provided would anything 0-9 inclusive.

Member Avatar for Dave Sinkula
0
157
Member Avatar for BlackPhoenix

Either: 1) change line 49 to: std::vector<GameObject*> myGameObjects; if you want an array of pointers to GameObjects so you can use newGO as declared on line 50. OR 2) add a public mutator function to set the id member of a GameObject calling something cute like setID(). change line 50 …

Member Avatar for Lerner
0
98
Member Avatar for aomran

If you've ever been to an old fashioned library you know that they have the books all filed on shelfs according to some plan. If you just walk into the library and start looking for the actual book it is very tedious. Howevr, if you search the card catalog, where …

Member Avatar for Lerner
0
70
Member Avatar for jsapp36

To my knowledge: If you want to add an entirely new set of customer data to end of current data stored in file without overwriting current data, then you can open the file in app mode to append the data to the end of the current file. If you want …

Member Avatar for Lerner
0
107
Member Avatar for trac15

I would insert each term in terms in ascending order based on the exponent so that the exp term with exponent 0 has index 0 in terms, etc. I would expand terms if the exponent of a term to be added to terms is above value of nterms. The default …

Member Avatar for iamthwee
-1
161
Member Avatar for Rastafari

try moving line 19 to line 17 so you don't assign tempPtr->data to tempValue each time through the loop. You only want to do that if the value of the conditional in the if statement is true.

Member Avatar for Rastafari
-1
88

The End.