1,608 Posted Topics

Member Avatar for gropedersen

The throw/catch stuff is nice, and eventually you should learn how to use it, but for now I'd concentrate on the use of stacks and use of classes/structs (the only difference between classes and structs in C++ is that struct members have public access by default whereas class members have …

Member Avatar for Lerner
0
752
Member Avatar for lsu420luv

The portion of the input file posted contains the data for two piano players, one with number 6010 and one with number 6012. The data is delimited by player with a -1. In this example each player has proficiency of 1 but one has weight factor 1.2 and the other …

Member Avatar for Lerner
0
667
Member Avatar for Roadkill

Often the flow would go like this: use startp to keep track of where to start use temp to search list use newNode to hold data to be inserted into list use stream to read from file use a loop to read all records from file to determine if there …

Member Avatar for Roadkill
0
107
Member Avatar for Saint48198

If you aren't allowed to use struct/classes to this as suggested by Ancient Dragon, then it can be done by using parallel arrays. This type of problem seems to be commonly assigned by instructors as a mechanism to get you working with arrays and as a mechanism to get you …

Member Avatar for Saint48198
0
170
Member Avatar for Acidburn

There's a learning curve in terms of how to effectively use error messages to your advantage. >>interpreter.cpp(16) : error C2065: 'Code_table' : undeclared identifier means that you used a variable called Code_table in the cpp file called interpreter that wasn't declared before you tried to use it. Misspelling the variable …

Member Avatar for Lerner
0
233
Member Avatar for grunge man

One way would be to: accept input as a string. convert string into an int convert int into a char (or cast int into a char if all you want to do is display it)

Member Avatar for iamthwee
0
365
Member Avatar for grunge man

look at the second post down from the top for some suggestions of books.

Member Avatar for grunge man
0
363
Member Avatar for weehoong

Here's a version using two files rather than holding the file contents in memory. Mirror the original file contents to a temporary file. Find the spot you want to change. Write the correction to the temporary file. write the rest of the original file to the temporary file. rename the …

Member Avatar for Drowzee
0
407
Member Avatar for YoTaMiX

In each call to the function i starts at 0, given the declaration int i = 0; Therefore you never check beyond the first elements of the array no matter how many times the function calls itself. The function will stop calling if the first elements of each string are …

Member Avatar for YoTaMiX
0
179
Member Avatar for tsubasa

Inputting material into the string will stop at whitespace characters such as space if you use the << operator to assign the information, but the string can have whitespace char if you initialize the string or if you use something like getline(). Once the string variable has a information that …

Member Avatar for tsubasa
0
137
Member Avatar for gampalu

Seeing as knowing how to write code requires you to know how to at least set up the algorhythm on paper here is site that reviews three ways to get an inverse matrix. None of them look fun. Maybe there's another way, too. [url]http://www.mathwords.com/i/inverse_of_a_matrix.htm[/url]

Member Avatar for iamthwee
0
255
Member Avatar for Kashif

cstdlib is the up to date version of stdlib. The older C header files like stdlib and stdio have been replace with versions prefixing the older version with a c, so stdlib became cstdlib and stdio became cstdio. If the compiler you are using won't accept cstdlib then try stdlib. …

Member Avatar for Ancient Dragon
0
217
Member Avatar for grunge man

use code tags anytime you are posting code to the board (or even text that you want to preserve indentation on as the board will eat it up otherwise)

Member Avatar for Lerner
0
290
Member Avatar for Kashif

atoi() converts a null terminated char array into an integer value (strtox() functions may be a better choice for this) rather than convert an integer value into a null terminated char array. The three options I'm aware of to turn integers into null terminated char array include: 1) sprintf(), as …

Member Avatar for Kashif
0
109
Member Avatar for degamer106

>>I can't think of a way to take individual numbers from a character array and store it into an integer array In general this often works for characters that are digits: int integerValue = array[i] - '0'; where '0' is the char representing zero and integerValue will be the integer …

Member Avatar for degamer106
0
92
Member Avatar for HelpMeImLost

>>The class contains two public data fields suspect you should drop the word public from that phrase and then proceed without the contradiction.

Member Avatar for HelpMeImLost
0
122
Member Avatar for cware

This is a declaration. Rectangle(double x=1, double y=1, double Height=10, double Width=10); The constructor still needs to be defined, just like any other method/function does. I would put the defaults in an initialization list and define it inline within the body of the declaration given the body of the constructor …

Member Avatar for Lerner
0
105
Member Avatar for Lerner

I have two structs: [code] struct Vertex { int row; int col; friend istream & operator >>(istream & is, Vertex & v) { char t[3]; is >> t; v.col = t[0] - 'A'; v.row = t[1] - '0'; return is; } }; struct Move { Vertex orig; Vertex dest; }; …

Member Avatar for Narue
0
135
Member Avatar for Podge

The good news is that you can write your class much cleaner like this: [code] class MyStorage { public: MyStorage() { } string MyString; double MyDecimal; int MyInt; }; [/code] All member variables of the MyStorage class still have public access. The :: operator should be used if you define …

Member Avatar for Lerner
0
118
Member Avatar for Kellaw

>>is there a specific function to push and pop No. It depends on the implementation. If you are going to implement your own stack then you get to decide how do set things up. If you are using a third party implementation then you use the functions provided without worrying …

Member Avatar for web_developer
0
855
Member Avatar for dors_zone

I think you are correct, the function determines the sum of the values in the array passed to it. In C/C++ the function whatIsThis() is called a recursive function. Recursive functions can be very useful.

Member Avatar for Lerner
0
157
Member Avatar for dors_zone

What you have posted looks like an ill fated attempt at a bubble sort. It bears some relation to the problem assigned, but not a whole heck of a lot. The relation to your assignment and the code you posted is that the body of the function you are supposed …

Member Avatar for Lerner
0
123
Member Avatar for vamsi.rgiit

I think your idea of selection sort is off. To me, selection sort means taking an existing container and then sorting it, rather than sorting it while you add items to it---which sounds like insertion sort to me, and appears to be what you are doing with your code. To …

Member Avatar for Lerner
0
61
Member Avatar for jack223

Or is it more when you consider the default methods added by the compiler, since the author didn't specify them explicitly?

Member Avatar for Lerner
0
96
Member Avatar for Kanvas

Pass thisCount, theCount and isCount to count() by reference rather than by value. HINT(use references or a pointers as parameters) Initialize all values in letterCount[] to zero rather than a 26 digit value of zero. (I think a single zero in the parenthesis will do it, but it's easy enough …

Member Avatar for Lerner
0
208
Member Avatar for hu_4life

Welcome. A couple things to help you out. First, as you can tell by looking at your post, posting code to bulletin boards frequently destroys the indenting used to make your code more readable. Most boards offer a fix for this, as does this board. You can read about it …

Member Avatar for hu_4life
0
2K
Member Avatar for some one

A singly linked list can be used to create a stack, but so could a doubly linked. It depends what you are most comfortable with. A queue and a deque are different containers. A queue removes the first item pushed on the queue, whereas a deque can remove either the …

Member Avatar for some one
0
87
Member Avatar for nthompkins

>>• Implement string concatenation and assigning one string to another string. • Implement multiple string and c-string class functions. I suspect you are to create your own string class and implement functions to perform concatenation and assignment. the STL string class already has concatenation, assignment, and a large variety of …

Member Avatar for nthompkins
0
186
Member Avatar for lsu420luv

It's not a good idea to use return value of eof() as a loop conditional as it commonly causes process body of loop one too many times. You would be better checking return value of attempting to read in the piano players number as the conditional. When the stream gets …

Member Avatar for Lerner
0
413
Member Avatar for Arvinth

You will probably get more help if you are more specific in what your question is and show effort of having worked on the problem yourself.

Member Avatar for Arvinth
0
323
Member Avatar for Acidburn

A table of strings with more than one string per row would be a three dimensional array of char. Say the table contained one string for the name and one string for the address per row of the table: Name Address John Milwaukee Jane Miami Depending on your needs, such …

Member Avatar for Bench
0
106
Member Avatar for 111Help

Do you mean something like this: [code] struct Time { int minutes; int seconds; friend ostream & operator<<(ostream & os, const Time & t) { os << t.minutes << " minutes and " << t.seconds << " seconds" << endl; } } Time timeUsed; Time timeRemaining; timeUsed.minutes = 46; timeUsed.seconds …

Member Avatar for Lerner
0
124
Member Avatar for akshayabc

[quote]As a creative alternative, you could write a penetration tool that tests the security of a network by trying to break in from the outside rather than works to ensure it from the inside. [/quote] Is intent all there is between viruses/worms/trojan horses and "penetration tools"?

Member Avatar for Narue
0
918
Member Avatar for darkstar80

I can think of no "good" way to do this. Some options I can think of include: 1) If records.txt isn't "too" big, read it all into a container in your program, search the container for the desired location, change what you will, and write the containers content back to …

Member Avatar for Lerner
0
91
Member Avatar for Nurul Dee

This is going to involve a lot of shifting of values stored in the array. You will end up shifting to the left when deleting any element other than the last one, and shifting to right when you add at any element but the last one. To shift to the …

Member Avatar for Nedals
0
361
Member Avatar for sladesan

Assuming your input file is in the form of a whitespace separated 10x10 table of ints then reading it in could be as straightforward as : [code] for(n=0; n<10; n++)// col. number { for(m=0; m<10; m++)// rows number { inClientFile >> array[m][n]; } } [/code] in your version: [code] for(n=0; …

Member Avatar for Lerner
0
862
Member Avatar for cesarmas

A couple things: I think you meant --InvDeqiter instead of --DeqIter otherwise the for loop will likely be never ending as the stop conditional relates to InvDeqIter not DeqIter. To read a deque or a double ended list backward using a reverse_iterator you increment the reverse iterator, not decrement it. …

Member Avatar for Lerner
0
180
Member Avatar for JoBe

With regard to maintaining arrays, set it up so when you do something to index x in array1 you also do the something to index x in array2. To find quartiles, I'd sort the array. Determine the total number of items in the array. Divide the total number by 4. …

Member Avatar for JoBe
0
285
Member Avatar for Lothia

should this : x_initial * time be this: vel_i * time and try putting this: vel_i = vel_i - (G * DELTA_T); // estimate new velocity for the next DELTA_T. after this: // Compute new velocity. cout << "The velocity of the cannonball is: " << vel_i << " m/s\n" …

Member Avatar for Lerner
0
1K
Member Avatar for fevershark

Thanks for trying to use code tags. Replace C++ within the brackets with the word code and it should work better next time. From the point of view of the C++ language, things look pretty good. You don't need a return statement if a method/function has return type void. From …

Member Avatar for iamthwee
0
375
Member Avatar for SkyFlyer1312

First: Please ask (a) specific question(s). Second: Where's the version of average with two arguments instead of three? Third: at least the two argument version of average() is supposed to return a double, not a T. Fourth: To me the instructions for the three argument version of average() are vague. …

Member Avatar for Ancient Dragon
0
160
Member Avatar for monique83

500000000 is 500 million or 5 x 10^9. 3*5 x 10^9 = 15 x 10^9 floats 8 bytes/float * 15 * 10^9 floats = 120 x 10^9 1gigabyte = 10^9 bytes Therefore you would need over 120 GB of memory (if I've done my math right) to do this all …

Member Avatar for Lerner
0
95
Member Avatar for comwizz

Here's my understanding of copy constructors. Copy constructors create a new object of the type of the class it is in from an already existing object of that type. Routinely, the data in the object passed is used to populate the data members in the new object so the new …

Member Avatar for comwizz
0
230
Member Avatar for JoBe

[code] Person::Person(const Person& copyName) : { cout << "Copy constructor called...\n"; m_name= copyName.GetName(); m_pNext = 0; //or m_pNext = copyName.m_pNext; if you want both copies to have the same address in their pointers. } [/code]

Member Avatar for Lerner
0
340
Member Avatar for wigster84

If the current protocol is satisfactory for you, so be it. You might also be able to accomplish essentially the same thing by processing each number as you read it in, rather than read in all the numbers at once and parse the whole file/string. To do that, I'd use …

Member Avatar for Lerner
0
111
Member Avatar for kahaj

There is more than one way to do most tasks. You can probably accomplish this task by using index values and an an array of strings. Develop a 2d array of strings to represent each word available. The first column could represent the scrambled word and the second the correct …

Member Avatar for winbatch
0
185
Member Avatar for Acidburn

move the cin >> change inside the while statement. Add a case -1 to the switch statement. If switch conditional switch conditionals must be a positive integer then check the value of change outside the switch statement in an if statement such that if change == -1 don't check the …

Member Avatar for SpS
0
139
Member Avatar for sam1

I think you need to write out the design of your program in your native language before you try to write up the program to do what you want to do. Expanding on this may work: A library is a collection of books. The information regarding each book is contained …

Member Avatar for dwks
0
212
Member Avatar for some one

Depending on your needs and knowledge something along these lines might work. This is only a rough outline of one possible way to proceed. If it looks like something that might suffice, it's up to you to fill in the details. [code] template <T> //use templated class for a general …

Member Avatar for some one
0
133
Member Avatar for emailsrs

dynamic memory in C uses malloc(), or a similar function, to allocate dynamic memory and free() to delete dynamic memory. In C++ it's new() and delete. In either case, if you want memory for an array of items then you add the [] operator, as appropriate. //allocate an array of …

Member Avatar for SpS
0
106

The End.