1,608 Posted Topics

Member Avatar for AltF4me

Use pencil and paper. I think you'll find you need to use 4 pointers, current, and a temorary node. Insert after current: temp = current->next; //keep track of this value //attach newInsert after current current->next = newInsert; newInsert->previous = current; //attach whatever current used to point to after newInsert newInsert->next …

Member Avatar for AltF4me
0
150
Member Avatar for MyrtleTurtle

It probably has to do with the implementation of unget(), though since I don't know how unget() is implemented I don't know that for sure. Having said that, if unget() puts the last value of ch back in the input buffer, but doesn't take the last value of ch out …

Member Avatar for MyrtleTurtle
0
125
Member Avatar for KBL

You can't compare char arrays using the == or the != operators and you can't compare C style strings (null terminated char arrays) using those operators either. To compare char arrays you need to use a loop and compare each char in each array one by one. To compare C …

Member Avatar for KBL
0
25K
Member Avatar for tallygal

Place all the code you want to repeat each time new stuff is read from the file inside the body of a loop, maybe lines 34 through 76, or something like that. Use line 35 as the controlling condition for the loop to run by placing it between the parenthesis …

Member Avatar for tallygal
0
112
Member Avatar for TheZea

All line numbers refer to post #4. Bigint::Bigint() Is the default constructor. I'd use it to to set num to be an empty string. Line 63 is an example of how to do that. As it stands now:[code] Bigint::Bigint(string str){ for(int i = 0; i < str.length(); i++) { num.push_back((str[i]));[/code] …

Member Avatar for TheZea
1
459
Member Avatar for zrd0808

You want to stop when n == end, not when n == start. The first value of n is start and you should never get back there again, if you aren't going to visit any vertex more than once. Try changing line 21 to printPathHelper(g, end, start); Change parameters in …

Member Avatar for Lerner
0
95
Member Avatar for YeMiller

Assuming the lines of the files are all in the same format as the two posted you can use getline() with comma as the delimiter to read the first part of the line and then another call to getline(), or a call to >> to read in the numeral. Beware, …

Member Avatar for WaltP
0
145
Member Avatar for sbdblyss

If the polynomial is restricted to a single variable polynomial then each node needs to have a coefficient and an exponent. You can recieve user input for each, individually or you can accept the full polynomial from the user as a string and break it down term by term until …

Member Avatar for Lerner
0
114
Member Avatar for som3aman

I think the problem is on line 93: getline(cin,newquestion,'\n'); Fair enough, but in addition to pointing to where you think the problem is it also helps to explain the problem. I will assume the problem is that the code isn't putting information into newquestion. If that's correct, then the problem …

Member Avatar for Lerner
0
2K
Member Avatar for Annettest

option 1: Each time you want to add a new column to the left hand side of the matrix declare a new, bigger matrix using dynamic memory, then load the data from the vector in the first column using a loop, followed by another loop transfer the data from old …

Member Avatar for Lerner
0
275
Member Avatar for Crow13

1) This is called edge detection which is often part of a validation process. If the x or y coordinate is above 17 or under 0 then that move is invalid so you can tell the user and ask for alternate input. Keep doing that in a loop until a …

Member Avatar for Crow13
1
119
Member Avatar for pvsumanbabu

Three thoughts. You might look up the ctime header file and see if there is a standard way to do what you want. Otherwise you can develop your own functions to do what you want. I don't think there is anything in iomanip that help you, but you could check …

Member Avatar for pvsumanbabu
0
107
Member Avatar for timbomo

These are the first lines of the function definitions: double calculateGrade(grade) int enterTotalQuestions(tot_quest) In the above, grade and tot_quest need to be preceded by whatever type they are. Since you define calculateGrade() and enterTotalQuestions() before main() instead of after, then the following lines can be deleted. double calculateGrade(double); int enterTotalQuestions(int); …

Member Avatar for Lerner
0
144
Member Avatar for fugnut

try declaring an empty STL style string. The concatenated each char to the end of the string. Store each string in an array and sort the array after input stops.

Member Avatar for fugnut
0
86
Member Avatar for CaninA

First, learn to use code tags when posting code to this board. It's not hard and it will preserve the indentation you hopefully have in the original code making it easier to read. Glancing through your code it looks like you've managed to use a stack. a queue and a …

Member Avatar for uchihakyu
0
260
Member Avatar for RobBobSmith

Matrix2d<int> mat; aMat.sizeMatrix2d(xA, yA) Line one above does indeed call your default instructor. In your default constructor you initialize rows and cols to zero and matrix to NULL. There is no memory declared there. Without seeing sizeMatrix2d() there is no way to know if there is a problem there or …

Member Avatar for Lerner
0
151
Member Avatar for pearle

[code]in main { create board and intialize to E declare plays and initialize to 1 declare no Winner and initialze to true while(plays < 9 && no Winner) { make play ++plays winner = win() if(winner != 'C') no Winner is false } if plays == 10 draw else if …

Member Avatar for usainbolt
0
4K
Member Avatar for techie929

Always start with a plan on paper that you write out with pen/pencil. For example, in this case you might try something like this: Determine mazeHeight Determine mazeWidth Use an array of type char to represent the removeable walls. Using dynamic memory and the formulas you described declare the memory …

Member Avatar for Lerner
0
104
Member Avatar for dude1

>>one person i talked to mentioned read the file as strings and tokenize the data is this a good way to do it? If the file is ordered as posted it wouldn't be that hard to create a class modeled around the information for each customer and to create a …

Member Avatar for dude1
0
172
Member Avatar for CVlaxstar

Try this:[code] //if any of the remaining coefficients is more than zero, then print out "+" for(int j = n-1; j > 0; --j) if(p.coefficient[j] > 0) cout << "+";[/code] Assuming degree is the largest exponent in the polynomial associated with a nonzero coeffieient then the degree of the product …

Member Avatar for Lerner
0
138
Member Avatar for thedonflo

line 0 has 1 star line 1 has 3 stars line 2 has 5 stars line 3 has 7 stars Without looking at the program how many stars does line 4 have? How many stars, call that number y, would line x have? Now try to write down on paper …

Member Avatar for Lerner
0
114
Member Avatar for timbomo

The math is square foot per room times 1 gallon of paint per 500 square feet. Then round that up to next int, which represents the number of gallons of paint to buy. Then multiply that int by cost of paint per gallon. Rounding up in C++ can be fun. …

Member Avatar for timbomo
0
204
Member Avatar for eternaloptimist

>>i want this program to find a name after i enter it. here r the names that i want to put into names.dat. Alternatively, create a section of your program to write whatever information you want to the desired file before you download the file back to your program. Not …

Member Avatar for Lerner
0
140
Member Avatar for Tech E

If you want to get the most "reuse" possible out of the struct you could put it in a header file by itself coupling it with an empty cpp file with the same name as the header file, but since the struct is so straightforward leaving it like it is …

Member Avatar for Lerner
0
108
Member Avatar for nizbit

>>I'm trying to increase the size of the array I'm confused with all the len, length(), pos stuff. Basically if array a is too small and you want to enlarge it, then you can copy the contents to a second array, temp, delete a, redeclare a with additional memory than …

Member Avatar for tetron
0
311
Member Avatar for Gnawk

If you wrote it presumably you know what's going on, or what you want to have happen, and might not be. If you have a specific question post it. As it stands there is plenty of questions you could be asking. I would prefer not to step in and tackle …

Member Avatar for Gnawk
0
128
Member Avatar for shimbouzi

Welcome to the board. Please read about using code tags when posting code to this board so that you syntax formatting is maintained. The information you need is in both the announcement section and the read me before posting post at the top of the board. The function getElements() will …

Member Avatar for Lerner
0
112
Member Avatar for mik3

Change the extraction function to take a reference to an int as an argument and return an int. Extract just the least significant digit from the number passed and return it to the calling function and remove the last digit from the number passed in, just like you did in …

Member Avatar for mik3
0
112
Member Avatar for ace8957

You could always post the function used to delete the database so we could look at it. Why do you load the database for each choice and save it to file everytime you change the data? Unless there's a reason to do otherwise keep the data in RAM as long …

Member Avatar for ace8957
0
177
Member Avatar for CreativeCoding

It is certainly possible, but the specifics of how to do it depend on how the file is set up. You need to know exactly how the file is set up and exactly what you want to do with the information you extract.

Member Avatar for Lerner
0
116
Member Avatar for calypso8

An int sounds fine. You might consider declaring a function to randomly select an int between 0-6 and passing it the array of players (as per StuXYZ) they can eliminate and have the return value be the int selected. If the element of the player array with the int selected …

Member Avatar for calypso8
0
1K
Member Avatar for Christoph928

Move line 32 to between line 14 and 15. Only call srand() once per program. Call srand() before any calls to rand(). Declare the variable answer in main() and pass it to thinkUpNumber() by rerence or store the return value of thinkUpNumber() in answer.

Member Avatar for Lerner
0
117
Member Avatar for xcarbonx

[code]int nums; cout << "How many numbers do you want to enter?: "; cin >> nums; cout << "Enter " << nums << "numbers:"; for(int count = 0; count < nums; ++count) { cout << "enter number # " << count + 1 << endl; cin >> num; }[/code]

Member Avatar for strmstn
0
113
Member Avatar for munadel

As per your first post, now find the min and the max value of the array and display the values to the screen so you can prove you have the correct value.

Member Avatar for WaltP
1
111
Member Avatar for rcmango

First welcome to the board and using code tags on your first post! void arrays::Talk(hold&, keep&) The correct syntax would be: void arrays::Talk(string& hold, int& keep) However, since both hold and keep are member variables they are accessable by all member functions irrespective of whether hold and keep were declared …

Member Avatar for rcmango
0
121
Member Avatar for kratosaurion

Welcome to the board and thanks for using code tags! In order for the value of toty in main() to retain the change done to it in drawmore(), you need to send it to drawmore() by reference instead of by value. Change the declaration of drawmore() appropriately. Not that you …

Member Avatar for Lerner
1
81
Member Avatar for Web_Sailor

1) In my version I'd use a third vector to hold the results which eleminates to erase from either of the two source vectors, but you can do it as you please. Are duplicates allowed in either of the source vectors or the result vector? 2) use two iterators, one …

Member Avatar for Web_Sailor
0
177
Member Avatar for ajjg123

[code]for(int i=2; i <= 100; i++) { bool isPrime = true; // Check to see if i is prime, print i out if it is. for(int j=2; j <= sqrt((double) i); j++) { if(i % j == 0) //what does the above line mean? //it means i isn't prime, true, …

Member Avatar for Lerner
0
147
Member Avatar for empror9

>>hoe can i disply a message to show the user that what he\she should to do? Maybe by displaying the required insturctions on the screen using stdout. Maybe something like this? cout << "You now have a bomb that can be used to blow up a wall." Such instructions and …

Member Avatar for empror9
0
158
Member Avatar for Vou

Doesn't relate to error messages, but: [code]void setSize( int astSize); void setSpeed(int astSpeed); int setSpeed() { return astSpeed; } int setSize()[/code] when you declare functions with the same name and different arguments it is called overlaoding the function. This can be a very useful tool. However, in your case I …

Member Avatar for Lerner
0
157
Member Avatar for C++new

There is plenty of memory available on the C++ forum server so please try to use complete sentences to clearly explain your problem and ask a pertinent question. As it stands I don't have the foggiest idea what question you are asking or assistance you areseeking. Maybe a moderator will …

Member Avatar for lotrsimp12345
0
152
Member Avatar for roc a

Programs don't write themselves. You need to have some sort of a plan before you can do anything. You have successfully created an array of 24 ints, assuming the closing curly brace was intentionally left off of your snippet for the purposes of you post or unintentionally snippet by the …

Member Avatar for Stefano Mtangoo
0
200
Member Avatar for squarey
Re: argv

I don't routinely use the command line so this response may be in error, but I don't think so. argc gives the number of arguments passed on the command line and argv the array of strings representing the arguments. So if argc is one the only argument passed is the …

Member Avatar for strmstn
0
69
Member Avatar for xschecterx

Start by defining what a perfect number is. Is a perfect number one that equals the sum of it's factors other than itself? If so, then determine all the factors of the number, arrange them in ascending order, and add all but the largest one together. If that sum is …

Member Avatar for clutchkiller
0
102
Member Avatar for fmma

First, you will need to learn how to use code tags, see the announcement and the sticky threads at the top of the board, when posting code to this board. Without many of the more respected people who visit this board won't bother to respond to your post because the …

Member Avatar for Lerner
0
152
Member Avatar for Teach25

Here's a brute force method that should work. Make a list of all line segments using every 2 point combination and count them. These line segments represent all possible unique lines defined by the set of points. However points, or line segments, that are colinear need to be taken into …

Member Avatar for mrnutty
0
136
Member Avatar for ELBUF

[code]ostream & operator << (ostream &out, BigNumber n) { double temp = n.getCoefficient(); if (temp == 0) { out << 0; } else { out << temp << " x 10^" << n.getExponent(); } return out; }[/code]

Member Avatar for ELBUF
0
126
Member Avatar for kotkata

while ( (choice != 'H') || (choice != 'h') || (choice != 'R') || (choice != 'r') ) //not sure why this is not working try && instead of ||. If I'm reading your code correctly, the only time you want the loop to run is if all 4 conditions …

Member Avatar for WaltP
0
283
Member Avatar for logicmonster

Looks like you are missin a } on line 53 to close the do/while loop and you have one too many } at the end.

Member Avatar for WaltP
0
177
Member Avatar for wwsoft

There is no single formula. In general you will find the amount of change in X and the amount of change in Y and add it to the current values of X and Y. Sounds like you could use trigonometry and then you'd have to decide whether to use radians …

Member Avatar for wwsoft
0
92

The End.