1,608 Posted Topics

Member Avatar for comp_sci11

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 …

Member Avatar for comp_sci11
0
152
Member Avatar for mitchelltab

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 …

Member Avatar for ~s.o.s~
0
158
Member Avatar for comwizz

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 …

Member Avatar for Lerner
0
4K
Member Avatar for Sealteam56

[code] if ( ( sscanf(buffer, "%d", &currency) == 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 …

Member Avatar for Sealteam56
0
129
Member Avatar for bigdill

[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() …

Member Avatar for jim mcnamara
0
69
Member Avatar for sgriffiths

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.

Member Avatar for sgriffiths
0
2K
Member Avatar for thehakan

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 …

Member Avatar for thehakan
0
149
Member Avatar for costantinos

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 …

Member Avatar for costantinos
0
130
Member Avatar for CStallion

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.

Member Avatar for iamthwee
0
143
Member Avatar for waseem3000

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.

Member Avatar for Lerner
0
269
Member Avatar for codergem

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 …

Member Avatar for Lerner
0
175
Member Avatar for aeinstein

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 …

Member Avatar for Dave Sinkula
0
384
Member Avatar for dude543

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 …

Member Avatar for dude543
0
144
Member Avatar for newgurl

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 …

Member Avatar for Rashakil Fol
0
206
Member Avatar for nanodano

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.

Member Avatar for Lerner
0
104
Member Avatar for newgurl

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 …

Member Avatar for newgurl
0
359
Member Avatar for achala

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.

Member Avatar for SpS
0
102
Member Avatar for takayuki

Have you tried changing the paremeter for setprecision to see how it affects the output?

Member Avatar for SpS
0
120
Member Avatar for achala

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.

Member Avatar for Lerner
0
149
Member Avatar for wwaall2004

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 …

Member Avatar for wwaall2004
0
365
Member Avatar for letish

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 …

Member Avatar for Lerner
0
509
Member Avatar for iamthwee

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 …

Member Avatar for Jessehk
0
649
Member Avatar for jack999

you only need a single array as a parameter to swap(), and only use a single array within swap.

Member Avatar for Lerner
0
180
Member Avatar for puppy

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.

Member Avatar for dubeyprateek
0
109
Member Avatar for dark808

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.

Member Avatar for Lerner
0
98
Member Avatar for ASH168

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 …

Member Avatar for Narue
0
150
Member Avatar for tydruk

[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 …

Member Avatar for tydruk
0
204
Member Avatar for tyczj

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 …

Member Avatar for Lerner
0
108
Member Avatar for john_hasan

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.

Member Avatar for Lerner
0
114
Member Avatar for tyczj

[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]

Member Avatar for tyczj
0
172
Member Avatar for Lomas

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 …

Member Avatar for Lerner
0
161
Member Avatar for ghadahelal

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 …

Member Avatar for Bench
1
254
Member Avatar for totalnewb++

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 != …

Member Avatar for dwks
0
146
Member Avatar for musicmancanora4

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 …

Member Avatar for Lerner
0
167
Member Avatar for derangedone

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 …

Member Avatar for Lerner
0
207
Member Avatar for CaliVagabond

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 …

Member Avatar for CaliVagabond
0
126
Member Avatar for mixsir

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 …

Member Avatar for siu05rr
0
161
Member Avatar for degamer106

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 …

Member Avatar for Lerner
0
332
Member Avatar for KimJack

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 …

Member Avatar for MIGSoft
0
356
Member Avatar for qgirl

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 …

Member Avatar for Lerner
0
138
Member Avatar for lulug76

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 …

Member Avatar for dubeyprateek
0
417
Member Avatar for NarenderKumarP

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 …

Member Avatar for NarenderKumarP
0
387
Member Avatar for jlouang

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 …

Member Avatar for jlouang
0
352
Member Avatar for mwo0002

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, …

Member Avatar for Lerner
0
124
Member Avatar for yaoyaolin

>> 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 …

Member Avatar for Lerner
0
91
Member Avatar for gminis3

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 …

Member Avatar for Lerner
0
194
Member Avatar for iamboredguy

>>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 …

Member Avatar for iamboredguy
0
164
Member Avatar for viet_mafia

[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 …

Member Avatar for Lerner
0
289
Member Avatar for Aldin

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 [ …

Member Avatar for Ancient Dragon
0
2K
Member Avatar for degamer106

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 …

Member Avatar for Drowzee
0
101

The End.