1,608 Posted Topics
Re: I'm sure there are multiple definitions of what a sentinel is, but I think of it as something that triggers an action. For example, if I want to do one thing if the variable called changeFunctions is true and another thing if the changeFunctions is false, then changeFunctions could be … | |
Re: The syntax is either way off for C or so confuscated as to be unreadable. Semicolons are missing or misplaced. It's hard to tell if there are function declarations or variable declarations. Etc. | |
Re: 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 what the declaration of a constructor looks looks like I suggest looking at your notes or class reference. … | |
Re: I don't routinely program in a graphics environment (to make pictures, lines, objects, etc), but when I do program in a graphics environment I use OpenGl. There are multiple online sources for assistance (nehe.gamedev.net is one nice resource) and by typing in install OpenGl in Google I get multiple hits, … | |
Re: Surprisingly enough, the vector class has a method, it's called erase(), that allows you to do just that. If you plan on writing code and using vectors I'd encourage you to get a reference that you can use to help figure this type of question out. cppreference.com is one such … | |
Re: You seem to have some trouble switching back and forth between STL string objects and C style strings (null terminated char arrays). I'd use one or the other for this project. You can use the [] opoerator on an STL string to acceass any givenn char therein. The STL library … | |
Re: First make sure the constructors and output functions work right. Then test the input functions. Then test each of the math functions separately, adding each to a menu/switch as you call them. | |
Re: int coeff[0]; declares an array with capacity to hold no ints. If you want to be able to specify how many coefficients will be in coeff at run time then you need to declare coeff with enough capacity to hold the largest number of coefficients an end user could possibly … | |
Re: WaltP is being (a bit) sarcastic (OP did indicate problem was in the sum() function), but he has a point. Many IDE programs will help you narrow down the problem line by indicating what line they think the problem is in, and if yours doesn't, then commenting out the lines … | |
Re: Honesty is always a good policy. So, I'm sorry, but the answer is no. Please see the homework policy at the top of this board. | |
Re: 1) int anArray[499]; That declares an array of 499 ints with valid indices of 0-498. If you want an array of 500 ints you should declare it like this: int anArray[500]; 2) In Driver.cpp lines 20 and 21 try to declare functions within main() which is a no no. To … | |
Re: C++ is case sensitive so bankaccount is not the same as BankAccount. In the .cpp file (if you are using files to keep track of things) you implement the class functions (class methods if you prefer that syntax) declared in the .h file. If you are implementing constructors or destructors … | |
Re: Ok, so I don't have compiler where I am, and even if I did, I don't have your .dat file, or an example of the information therein, so I couldn't test your program even if I did. Having said that I offer the following: 1) Don't use the output of … | |
Re: find position n - 1. Call it temp. Then write a function that returns nothing, takes no parameters, and deletes temp->next, as long as temp->next isn't NULL. | |
Re: if k is controlling the index of the array you are using (lines 20 and 21) then why do you keep setting the value of k to either 1 or 2 in lines 28 and 30? | |
Re: A menu is often a set of choices, like enter + to add 2 numbers , enter * multiple 2 numbers, etc. printMenu() would print out all the options you want the user to have. If your instructor has given you a specific menu to construct, use it. If not, … | |
Re: Try using another variable, say k, to keep track of the current "size" of the shape whereas n is the maximal size of the shape. Set k = 1 before the second do while loop, change the i <= n to i <= k in the for loop, increment k … | |
Re: Please be more specific in the description of what you are trying to do. The way I read the first sentence it looks like you want to find a set of characters in a text file, say all the vowels in a piece of text like "eenie meenie minie mo". … | |
Re: Post only the code you think is relevant to a specific question. If a respondent feels more code would be helpful then they will likely ask for it. One on one tutoring is not the goal of this site, though there may be such sites available on the web. The … | |
Re: I erased my original post because I neglected to check page 2 of the thread. make_pizza(char variety, int n) sounds like you need to add_flour(), add_pepperoni(), add_vegetables(). The amount of flour, pepperoni and vegetables you need to add will probably depend on the values of those ingredients associated with the … | |
Re: 1) Use an fstream in in mode or a dedicated input stream called and ifstream. 2) A given linked list represents a given polynomial. Each node in the linked list represents a term of the polynomial (a term means a coefficient a variable and an exponent of form cx^e). The … | |
Re: Use a loop printing one space to the screen each time through the loop. When you are done with the loop it will look like you printed a string of spaces all at once. As an alternative to doing everyting on the fly you could use two arrays (tables) of … | |
Re: First things first. Welcome to Daniweb. Your ability to post code with code tags on your first post puts you at the head of the class! Having said that, there are a couple things I would suggest. #1) When writing code using standard C++ try to avoid using global variables. … | |
Re: j is incremented by one each time through the loop. On line 11 is the instruction to break out of the loop if j is over 12. So it seems like the code is doing what it has been written to do. | |
Re: This is dependent on the platform you are writing your program for, Windows/Linux/Mac. There are forums for this indiviual platforms if you go to the forum index and scroll down a ways. You may get an answer here, but you are much more likely to get a response in the … | |
Re: Unless you are using somebody elses program you can't do standard deviations by just turning on the computer. Someone needs to write a program to do it. In this case it's you. One of the useful tools in writing programs is to recognize patterns. Another is the ability to break … | |
Re: You need to be much more specific with your request. Are you trying to make a 25 char string using 5 separate, unrelated 5 char substrings? Can the substrings be of variable length as long as the total char in the string is 25? What characters are valid to use? … | |
Re: Your objective isn't very clear. Where does the array called table come from? I assume it's an array of type info, but I don't see any declaration. I assume you want to print out the contents of table so that the information printed to the screen looks like the file, … | |
Re: char * longInt = new char[x]; Now longInt is a char pointer pointing to the first element of a container of x number of elements of type char. That means that longInt acts like an array, though technically it isn't an array, but that is a discussion I still don't … | |
Re: Your problem would be easy to solve with structs/classes, but it is doable even without them. Let's say each waiter could have up to 25 orders at any one time. Each order could have a customer identifier (seat number, customer name, whatever) and each customer could purchase one or more … | |
Re: I can't explain the exact cause of your error message or why it complains the way it does. I can tell you that binary_search() takes either 3 or 4 parameters. The first is a location to start, the second a location to stop, the third is a single value to … | |
Re: You appear to have two arrays, one with the name of the product/item and the other with quarterly prices. The row index of the prices is the same as the index for the product name. In mice() you want to evaluate the data for each product. In order to do … | |
Re: I would have thought that using this input: 1, with this syntax: fin >> a[i][j]; where a[i][j] is an int would result in fin going into an error state and that the stream would need to be reset/clearred before the char, the comma, that caused the error could be ignored. … | |
Re: There are several ways. Since the space char is a character, notated like this: ' ', you can look for it directly. Otherwise you can use a function related to isalpha() called isspace(). However, isspace() looks for all whitespace characters, which includes the space character as well as the tab … | |
Re: Notice the different placements of the curly brackets betweenn the code written by Clinton Portis and your code. He checks the value of counter within the while loop to start a new line if needed, you check it outside the while loop. Try this:[code] #include iostream using namespace std; int … | |
Re: In addEnd() assign address for the new node to q, not current. Be sure to assign y to q and to make each pointer in q NULL before adding it to tail. If head == NULL then assign q to head and q to tail and you're done for that … | |
Re: As far as I can tell this should be the basic logic for the program [code] main() int balance int wager bool oneMoreGame while(balance above zero and oneMoreGame) enter wager check if wager less than balance and redo wager until it is gameResult = runGame() if gameResult is lost deduct … | |
Re: You could create a passenger class with just a string object, ie a name. Then you could have a seat class which has several variable members including a passenger, a row number, a seat number and a char to keep track of whether the seat is occupied or not. Lastly … | |
Re: The new operator returns a pointer (address) of the object(s) that memory has been allocated for. That pointer must be stored someplace in order for it to be gain access to the memory. When the [] operator is used to allocate memory for a group of objects then memory will … | |
Re: >>I can't work out how it would take value1+value3+value15 over just value1+value2. That should be doable by using two variables of type long to keep track of the closest value yet and the difference between the best yet and the target and a third variable that is an array of … | |
Re: But using tools when appropriate is an important skill to learn. Sometimes it's not appropriate to create classes or use inheritance if the problem can be better solved using other mechanisms, and to me, trying to force inheritance on a system that isn't suited to it doesn't help you learn … | |
Re: A stack is a virtual container that behaves something like an array but has restricted, instead of random access, to whats inside. The first thing you need to be able to do is be able to identify separate words (also known as tokens or substrings or whatever). Using the enter … | |
Re: Think of the plot mathematically as an x and a y component, but think of the plot visually (to print) as a series of lines of spaces and crosses. Fill a 2 dimensional array with spaces. Then add a cross to the cell that demonstrates what y would be at … | |
Re: You need to write the code yourself. If you want to blow them out of the water then check if secondNo is zero and if so exit the program. If you want to be user friendly then you can detect that secondNo is zero and use a loop to continually … | |
Re: Look up toupper() and tolower() in your favorite reference material. | |
Re: Do you want to create your own operating system or do you want to something a little more simple, like implementing an inventory system or maybe a game like battleship? All of these, and many more, can be done with the tools you list. since none of us know what … | |
Re: I don't believe C++ allows type double to be the index of an array/vector, so I'm surprised that the posted code would compile. If c2 were of type int and you were to increment it's value by 1 starting at 100 and stopping at 499, then the code as posted … | |
Re: Need more input. What is the declaration for the xCards? If they are Cstyle strings then you can't assign one to the other and if they are STL string objects then they won't work with strcpy(). For Cstyle strings there is a strcat() function that will concatenate one string onto … | |
Re: If each entry in the file is comma separated(every field separated by a comma, no new line char or other whitespace), then you can read the file using getline() with the comma char as the delimiting char to "find" each comma. After each read from the file into a string … | |
Re: Welcome to the Board! You're off to a good start with your first post. You figured out how to post code using code tags, you use consistent indentation, you have commented your code, and you asked a relevant question. Here are some comments: In general: 1) The return type of … |
The End.