1,608 Posted Topics
Re: id, f, l, and m are all arrays. id is an int array which may contain up to MAX = 100 ints. The first int in id is id[0], the second is id[1], the third is id[2], etc. f, l, and m are char arrays. If the char array is … | |
Re: I'd say you're on the right track but: 1) please place code posted to this board inside code tags to preserve indentation. If your code truly looks like that, then please learn how to indent. 2) Your instructor put this [quote] remember to develop and test your code one section … | |
Re: Your stack is a doubly linked list with restricted access to the links in the list. The links themselves need to do nothing (they could display their value if you want but other than display themselves they do nothing) so remove everything from abc but the member variables (and write … | |
Re: [code] if ( ( sscanf(buffer, "%d", ¤cy) == 0) || currency > 99999 || currency < 1 ) { ///////////////////////////////////////////////////// printf("\n\n\a This is an Erroneous amount based on your input\n"); [/code] First I'd try placing an output statement to indicate the value of currency and buffer at the place where … | |
Re: [code] #include <iostream.h> #include <stdlib.h> /* If you put a semicolon at the end of this line, then it becomes a function prototype. It tells the compiler/linker/whatever that you will be using a function by the name of My_Name_Is which takes no parameters and doesn't return anything. */ void My_Name_Is() … | |
Re: I don't do much in the way of I/O using C. However, this reference: [url]http://www.cppreference.com/[/url] indicates that "rb+" opens a binary file for read/write operations. Good luck. | |
Re: friend functions are allowed access to private data members of the respective classes. Lets say you had this: [code] class listNode { int data; listNode * next; }; [/code] Then let's say you want to let listNode objects display data on the screen. Remember, by default all member variables and … | |
Re: I'm not familiar with the I/O protocol you are using, but since you have the iostream header file included in your program you could also add the fstream header file, declare an fstream in input mode or use an ifstream (which is an fstream in dedicated only to input), and … | |
Re: An array of STL strings seems a little strange. Have you considered using STL vectors instead of arrays? They have a built in size() member, no calculation on your part is needed. ![]() | |
Re: Once you have the C++ errors corrected I think you will find that the program logic needs a little tweaking as well. If so, post a program with the C++ errors corrected and I can post pseudocode for what I think is some improved logic. | |
Re: A list is made up of zero to x nodes, where x is limited only by the amount of memory available. If there are nodes in the list then it has a first node and a last node. You have to keep track of the first, as it's the entry … | |
Re: I hesitate to enter this discussion, but I can't help myself given how long it took me to understand the difference between >> and getline() myself, and even now I'm not confident that I have it all correct. [quote] I prefer the "read all input as a string and convert … | |
Re: To me node three is the start of the loop, not node two or node 10, both of which point to node three. I agree that node 10 is where the error is, if you are looking for the error, but it isn't where the loop begins, IMO. In any … | |
Re: Following is a detailed critique of your program as posted and an incomplete program demonstrating how I would use parallel arrays to complete the project. [code] #include <iostream> #include <string.h> using namespace std; void printGenericHeading(int&, int&); void printCustomerHeading(int&, int&); void readId (int& , int& , int& ,int&, int& ); void … | |
Re: You might want to look into deque. It is basically a vector that has been modified to facilitate ease of deletion from front end operations. Deques are useful when you want to allow insertion or deletion at either end of the structure and you also want sequential access of elements. | |
Re: You could try something akin to this: [code] struct invoice id name and address date and time items container amount total while successful input into id if current id same as prior id continue on same invoice else complete current invoice start new invoice input into item if item equals … | |
Re: I would doubt there is a function in the standard that will do this, but I also don't think it's that hard to do it yourself. | |
Re: Have you tried changing the paremeter for setprecision to see how it affects the output? | |
Re: Assuming you have enough memory, passing a list/vector should be faster than file access for the same information. Passing by reference does expose the material being passed to being changed, so remember to use the keyword const judiciously if you don't want that to happen. | |
Re: Well, the directions indicate you need to set up 5 arrays, so that might be one step you could take. This shouldn't be too hard, if you've been paying attention in class and doing the homework to date. Then you could set up a display menu and declare a variable … | |
Re: Frequently the success of the answer depends on the success of the question. a) Are you using a GUI like Windows or Mac or something else or are you just trying to get the ASCII value of the enter key or are you just trying to get the value of … | |
![]() | Re: c_str() returns a const char []. bull() takes a char [] as a parameter. That means that any changes made to char[] in bull() should be valid changes in c_str(). However since c_str() returns a const char [] it can't be changed. Therefore the compiler throws an error. Hence, you … |
Re: you only need a single array as a parameter to swap(), and only use a single array within swap. | |
Re: The syntax error being reported means you have to return highest, not the highest derefenced. The logic error is that you need to have the ability to change the value of highest so don't try to force highest to be a const double in the first place. | |
Re: Visual Basic is what pops into my mind first, but I'm sure others will definitely have other opinions. C++ can do it, but it's not a rapid development environment, it's a language with all the twists and turns that come with languages. | |
Re: To deep copy a C-style string you need to declare enough memory for the string new copy and then use strcpy() to copy the contents of the old string into the new string. If you are deep copying an array that isn't a C-style string then you need to declare … | |
Re: [quote] i can't make the program calculate the time between(vahe) the departure(valjus) of the same number buss [/quote] No compiler available so I can't download cpp files. In general there are several ways to approach this: 1) you can transform hours and minutes to seconds, subtract the number of seconds … | |
Re: One of the principles of coding is to break a big problem down into smaller problems. You apparently want to create a dealers boot with 8 decks. So figure out how to create a card and then do it eight times. Once all cards are created shuffle them. Don't try … | |
Re: We wish you luck. When you have a specific question about how to proceed, compile or runtime errors you can't figure out, etc. follow the guidelines for posting in the FAQ and the stickies at the top of the board. | |
Re: [code] void Player::printHand() { list<Card>::iterator start = hand.begin(); //start "points" to a Card list<Card>::iterator stop = hand.end(); for( ; start != stop; ++start) { start->print(); //use the print() function of a Card cout << endl; } } [/code] | |
Re: You may be experiencing ambiguity. int numbers[] and array_size passed to sort() as parameters are the same names as member variables. How is the compiler to know which to use? Also, the member variable int numbers[] is never allocated any memory, yet you try to use it in print(). Try … | |
Re: ignore() is member of the istream class. It will ignore char stored in the input stream buffer. It is commonly used as part of an overall data validation process, but it can be used in other circumstance as well. I agree, a better description/example of what the OP is trying … | |
Re: I'd put a call to a function called showMenu() in getCommand() before doing your sequential if/elses. Then you can write out your menu in showMenu(). you can't do use the logical OR operator like this: if(again!=1||2) while(again!=1||2) It has to be: if(again != 1 || again != 2) while(again != … | |
Re: while(fgets(temp, LINE_LENGTH, f1)!=NULL) { newCat = NULL; prevCat = NULL; currentCat = NULL; newCat = malloc(sizeof(CategoryType)); if(prevCat == NULL) { menu->headCategory = newCat; } else { In the above snippet prevCat is initialized to NULL each time the loop starts to the conditional of the if statement will always be … | |
Re: Sure, you could build a queue around an array, but it may be easier to do it around a list. Any structure that allows you to remove the first item entered first work. The problem with arrays is that they are fixed size. So in order to not overflow and … | |
Re: Arrays are a block of contiguous memory with enough memory to hold a known number of elements. Each element must be of the same type and will therefore take up the same amount of memory. So if I have an element that will take 1 byte of memory then an … | |
Re: Wouldn't it be nice if you could just change the value of two variables and be able to use the same code for any 2 dimensional array? Well, you're in luck. Just change the value of the two const ints declared in main() in the minor variation of Narue's original … | |
Re: Here's my initial thoughts on the process: The input is a string representing the infix notation of the expression and the return value will be a string representing the outfix notation of the expression. The function will be passed the input string and an int representing the index of the … | |
Re: Well, you're going to need to gut out your own linked list code (that's the hardest part of this assignment, really). Then you'll need some mechanism to gaurantee that the last item entered into the list is the first item removed from the list. NOTE--that doesn't necessarily mean that the … | |
Re: I would probably have another class called Selection that contains a menuListType to represent the selection and an int to represent the number of that menuListType selected. I would store each Selection in a container of Selections declared in main and send it by reference to getData() and displayCheck(). You … | |
Re: I asssume you meant you can't fiqure out why my binAddCal function is not working. Assuming that's the case, here's how I'd Given: Usually we write numerical values with largest placeholder to the left and lowest to the right. However, that is convention only. It could be the other way … | |
Re: Your dilema seems vague. I assume you have developed a 2 dimensional table of values like tableName[rowIndex][colIndex] and each column has a name/header/identifier. I further assume you want to be able to find a given column identified by it's name/header/identifier and be able to access the elements of the column … | |
Re: First, don't have two variables with the same name: int month; char * month[12]; So let's say you change: int month; to int num; Then to use the cout << syntax it would be cout << month[num] << " " << day << " " << year << \n; or … | |
Re: Until you get much more experience never write a complete project and then compile. If you're as good as Narue, Salem, or Ancient Dragon you may get away with it, but for the rest of us mortals it is a recipe for disaster. Write a single task, or at most, … | |
Re: >> how can i set the maximum number of character to be 96. I assume you want to set the size of an array to be 96 as a maximum. To do that just place the value of 96 between the square brackets when you declare the array. However, a … | |
Re: an array is a collection of elements of the same type. a C type string is an array of type char where the last char is a null char. Each element in an array can be accessed individually using the [] operator and an index which is an integer representing … | |
Re: >>swap an element in a matrix with another As an example, if you had a matrix like this: int matrix[3][3]; and you wanted to swap the element in the third row and second column with the element in the first row and first column then you could do something like … | |
Re: [code] //find the smallest of the three if second less than first swap first and second if third less than first swap first and third //find the smallest of the remaining two if third less than second swap second and third //first is now smallest, with third largest and second … | |
Re: As a new member to the board it will behoove you to read the instructions on how to post code to maintain the indentation protocol you wrote the code with. To do that, enclose any posted code in code tags, that is [ code ] before the code and [ … | |
Re: Each address for each node in the circle is (usually) obtained from malloc() or new or some similar process. Each node contains the address of the next node in the circle. If "a points to b points to c points to a" it doesn't matter where the circle starts or … |
The End.