1,608 Posted Topics

Member Avatar for Lerner

Suppose you have a node declared like this:[code] struct node { int data; node * next; };[/code] and a list class declared like this:[code] struct myList { node * head; node * tail; int numNodesInList; //member functions etc, but no other member variables. };[/code] Then what is the size of …

Member Avatar for Lerner
0
158
Member Avatar for hsquared

I may be missing something here given the antihistamine I took an hour ago, but since I've never hesitated to sound foolish in the past I shan't be bashful at this point either. What size is a list and how would the compiler know how much memory to sequester for …

Member Avatar for Fbody
0
141
Member Avatar for Peter_morley

for(int index = 0; index > 11; i++) Couple of things with this line: #1) Hopefully i++ is a typo for ++index or index++. #2) The line as written says starting with index equal to zero increment i(ndex) by 1 each time through the loop as long as index is …

Member Avatar for Fbody
1
192
Member Avatar for MAbebe

[code]void final_grade(grades& the_grades); { cout << "Enter the score of the first quiz: "; [/code] Try removing the ; at the end of the first line posted above.

Member Avatar for chococrack
0
165
Member Avatar for bmos31

When you can, always try to figure out what to do and what happens using pencil and paper before you write the program. In this case I would create a table: For mailboxes with indexes 0-9 (10 mailboxes)all starting with value 0:[code] index 0123456789 interval = 2 0101010101 interval = …

Member Avatar for bmos31
0
826
Member Avatar for wittykitty

Are you sure it's an endless loop? Unforturnately, despite the name outputResult() I don't see where any output is coded in the function so it might look like it is just grinding away when in reality it isn't written to do anything we humans can appreciate. Renaming outputResult() something like …

Member Avatar for Lerner
0
134
Member Avatar for nizbit

Note how the pseudocode written by dusktreader doesn't really "remove" duplicates from the array. Instead it manipulates the duplicates such that the "duplicates" can be ignored, or removed from consideration, eventhough they aren't physically removed. Indeed there is no way to remove the memory from an array once it has …

Member Avatar for dusktreader
0
538
Member Avatar for XMasterrrr

The best of anything is generally a subjective rating. Find a book you feel comfortable with and go for it. All of the books listed in the sticky note have their supporters and detractors. This generally means going to the book store and browsing throught the options. If you don't …

Member Avatar for XMasterrrr
0
170
Member Avatar for KimJack

You could use a copy of the original string and break it up into substrings one at a time with a loop and strtok() using space and whatever else you want (punctuation characters, whatever) as a delimiter. Or, if you know the string won't have punctuation characters you could use …

Member Avatar for genext.brite
0
2K
Member Avatar for jelinky

You don't HAVE to use an array to hold all the scores, as arrays are just groups of individual variables of like type stored in contiguous memory. However, it is certainly neater to use arrays. The grades are arranged by how many answers were done correctly out of the 10 …

Member Avatar for VernonDozier
0
192
Member Avatar for Redhaze46

Writing an entire operating system to generate your own brand of windows would be possible with C++, but it would take extensive knowledge of both how operating systems work as well as how current gui's work, whether written with C, C++ or some other language. Creating your own text editor …

Member Avatar for NicAx64
0
132
Member Avatar for myd5258

Is there a reason you don't want to shuffle the cards in the deck to generate a random sequence of cards and then deal cards from the deck to each hand rather than assign random cards from a standardized deck sequence to a given player? The program flow could be …

Member Avatar for Lerner
0
428
Member Avatar for exekiel101

You are trying to use dynamic memory to create a multidimensional array (in this case 2 dimensional) but you have the syntax a bit off. Since you've asked for the number of rows, you should probably use them. [code] int ** table; //table is a pointer to pointer that will …

Member Avatar for Duki
0
77
Member Avatar for beverlyjojohnso

>>I think I will have to use a formula that will divide the number of seconds into hours, seconds into minutes, and the remainder will be seconds. Yup, pretty close. You can use division, modulo, and/or subtraction in sequence to do what is needed. NumberOfHours is InputSeconds divided by NumberOfSecondsInHour. …

Member Avatar for kommissioner1
-2
2K
Member Avatar for cpeepee

If the text you are reading is from a file, then the code posted should work pretty good as the >> operator should successfully separate the text into individual words based on finding whitespace characters. However, if you want to read from interactive user input you have a bit of …

Member Avatar for cpeepee
0
154
Member Avatar for The_Prince

If you use a char array then you can use a sequence of nested loops, wherein each char is associated with a loop, to change each place holder in the sequence in turn. Haven't used bitsets so can't say if similar manipulation possible with them.

Member Avatar for Lerner
0
112
Member Avatar for John Sand

Suppose textstring an STL string object and the content of the string is "My 7th program". The goal is to calculate how many of each letter there is in the string by looking at each char in textstring one at a time:[code] int len = textsting.length(); //determine the length of …

Member Avatar for John Sand
0
174
Member Avatar for cnmsg007

You don't need a nominee class if you don't want to. You can just give the Particular class a member variable of type bool of name nominee and if the member variable value is true, then the member is a nominee and if not, then they aren't. In addition you …

Member Avatar for Lerner
0
118
Member Avatar for Stony

Just look at one function at a time. Write, compile, and debug your code until it works. Then go on to the next function, etc. Don't look at the whole thing at once and panic.

Member Avatar for dusktreader
0
243
Member Avatar for gallantlex

Why declare gpa as an int and then default it with a value that's either a float or a double? Why declare and define >> and << and then not use them? Why use read() and write() instead of >> and <<? Why are you trying to flush an input …

Member Avatar for gallantlex
0
967
Member Avatar for helpme87

_strdate is a function, so calling c_str() won't help any. This might work: ofstream out(_strdate(dateStr)); or maybe this will do: ofstream out(dateStr); Be sure that 09/12/11 is a valid file name though. I'm not sure that it is.

Member Avatar for helpme87
0
156
Member Avatar for PaKmAn

I think of dynamic memory whenever I have to wait for user input to determine the size of an array. A table is usually a 2 dimensional array. A multiplication table is probably a 2 dimensional array of size x by x where x is both the number of rows …

Member Avatar for Ancient Dragon
0
119
Member Avatar for magician89

Don't push size number of tokens onto the stack all at once, push input onto the stack only if the information entered is an int. Swap lines 26 and 27 since top starts at zero, which is a valid index, and will be necessary if you want allow up to …

Member Avatar for aman rathi
0
153
Member Avatar for gaurav_13191

Maybe it does, and maybe it doesn't. The first thing to do is to pause the program after the call to insertion sort and before the return line in main(). Calling cin.get()or cin >> x once or twice usually does the trick. If you can pause the program and there …

Member Avatar for gaurav_13191
0
93
Member Avatar for jpeg

Don't get overwhelmed. Break things down into smaller parts and develop them one at a time. For example, first review the process by which you declare a class and how to declare attributes (variables) and actions (methods) you need/wish the class objects to have. Then try to write out the …

Member Avatar for -ordi-
0
192
Member Avatar for daviddoria

The stack class doesn't have to have a front or a back, it just has to have a top, which may be the first or last (or some other) element of a list or vector (or some other container). So it doesn't make sense to have an iterator or a …

Member Avatar for AuburnMathTutor
0
5K
Member Avatar for jos_t_tarigan

Since fread() is C style file reading instead of C++ style file reading you might do better to post this question in C forum.

Member Avatar for Lerner
0
84
Member Avatar for rokz84

In your first program be careful with your variable names. Making them more descriptive might help. Also adding comments to indicate to yourself what each loop is doing should help you find some errors. In your second program, temp is a char array, and C style strings are char arrays, …

Member Avatar for vocater
0
119
Member Avatar for c++learner

>>I have a 2D array of 10x10 and I want to search the surrounding cells of only a 3x3 portion of it at a time I'd use the corners of the 3x3 section and then 4 loops to get the sum of cells surrounding the 3x3 section. Since this doesn't …

Member Avatar for c++learner
0
141
Member Avatar for rv_mup08

Standard headers are routinely enclosed in angled brackets rather than double quotes. main() should have return type of int, not void. Using the void return type isn't standard and is one more keystroke than int to type. You need to declare all variables before they are used. You did so …

Member Avatar for rv_mup08
0
2K
Member Avatar for googles_go~

Declare a user defined class containing two variables, an ID and a PIN and at least an overloaded equals operator Declare two objects of the above class, one called user and the other called target obtain user input for ID and PIN for user. Validate input if desired. associate the …

Member Avatar for jonsca
0
312
Member Avatar for Jackie91

What does int data[] have to do with anything? And why is value being declared as an int if it's a string you want to be looking for? If value is the string you want to search for in an array of strings then pass an array of strings and …

Member Avatar for Lerner
0
152
Member Avatar for creative9k

Do you know the difference between C style strings and STL string objects? Do you know how to compare two C style strings? How about two STL string objects? Do you know how to declare an array? How about an array of ints? An arrary of C style strings? An …

Member Avatar for Andreas5
0
187
Member Avatar for Lusiphur
Member Avatar for neuelen

Since the format of the input is known in advance and it is a very structured input you could use a loop calling getline() nine times with comma as the delimiter followed by a single call to getline() using the new line char as the delimiting char to read each …

Member Avatar for neuelen
0
105
Member Avatar for eng.M

What do you think it does? Write out what each line means and it should be easier to figure out.

Member Avatar for eng.M
-1
94
Member Avatar for smoothe19
Member Avatar for smoothe19
0
169
Member Avatar for hg_fs2002

If you want to add to the end of the list you need to either keep track of the end of the list using a dedicated node called something like tail or end or whatever, or you have to find the end of the list by looping through the list …

Member Avatar for hg_fs2002
0
99
Member Avatar for Jackie91
Member Avatar for Jackie91
0
76
Member Avatar for saransh60

void main is wrong. main should always return an int as in: int main(). The constructor doesn't need to be initialized like that, but it is a good idea. It basically cause str to be an empty string instead of str being some junk value. Declare and define both a …

Member Avatar for sfuo
0
144
Member Avatar for fenerista

You can do a char by char analysis of the string looking char one at a time using (usually somewhat convoluted) logic to determine what is legal to follow any given char, particularly if you want to handle something like "6 - (- 54 - (-61))". That space between the …

Member Avatar for fenerista
0
120
Member Avatar for adaniel058

This fairly screams for user defined types. I am thinking of 2 types: cell and ship. cell would keep track of where on the board the ship is placed and which cells in the board have been selected. Each cell would have an x and a y value in addition …

Member Avatar for Silvershaft
0
177
Member Avatar for creative9k

[code]start x at 1 while x less than 4 display x start y at 0 while y less than 10 display result of x times y followed by a space increment y by one start a new line increment x by 1[/code]

Member Avatar for creative9k
0
146
Member Avatar for alan4545

Describe in your own words what getD() is supposed to do. Here's the best I can do with what you've posted so far: 1) define method getD() for class TWQ which will have return type void and be passed a copy of an AnsiString object, an array of Node objects, …

Member Avatar for annaabella
0
108
Member Avatar for johndoe77

Create a container to keep all the selections in it. The container may have any number of items in it. If you have been advised that no order will have more than 7 items associated with it, so be it, but it could have 1 or 3 or 4 or …

Member Avatar for Fbody
0
123
Member Avatar for hazel0419

You can't. If you had 5 variables of type char with values of A through E, then you could sort them.

Member Avatar for Lerner
0
46
Member Avatar for SacredFootball

You still haven't provided the definition of getInFile(), but from the behaviour you describe what is likely happening is that you are associating a file with an ifstream in getInFile and then returning that ifstream. The problem is that each time you call getInFile() from within the loop conditional you …

Member Avatar for Lerner
0
210
Member Avatar for hitmanner

You have several options. Here's one:[code] char ** strings; strings = new char* [501]; //display an array of 501 char pointers. for(int i = 0; i < 501; ++i) strings[i] = new char[41]; //each of the 501 char pointers will have the address of the first char in an array …

Member Avatar for amin_a
0
357
Member Avatar for vishalkhialani

A couple ways are: 1) include a flag within the data of each record indicating that this record is to be ignored and leave it within the file. Works nice if file storage isn't a concern 2) or keep track of which records have been "deleted" and can be overwritten. …

Member Avatar for 1988Rhythm
0
182
Member Avatar for VorSec

Not literally. But to see what is available you can go to cpprefence.com and look up the methods in what they call C++ String .

Member Avatar for iamthwee
0
1K

The End.