537 Posted Topics

Member Avatar for DynamicMember

the previous post makes me want to jab an ice pick into my eye sockets.

Member Avatar for JSPMA1988
-3
139
Member Avatar for Clinton Portis

As a proud memeber of the 10% unemployed and the 45% under-employed, I often find that I have a lot of time on me' hands. Now my dear ol' mom likes to play this game, and she's often at home alone.. so with nothing else to offer this holliday season, …

Member Avatar for Clinton Portis
0
166
Member Avatar for Awais Ali mugha

I see that you have went out of your way to captivate us with your innovative post and well written description of your problem. However, despite your exhaustive efforts to ask a smart question, I am still curious.. how much of your homework assignment have you completed thus far? Please, …

Member Avatar for arkoenig
-4
91
Member Avatar for Lando_

[quote]Write a program that asks the user to enter and item's [B]wholesale cost[/B] and its [B]markup percentage[/B]. It should then display the item's retail price. [/quote] Based on the above requiremet, it would make sense to me to have a funtion that takes two arguments: a wholesale cost and a …

Member Avatar for jember
0
2K
Member Avatar for sanjuanair
Member Avatar for seanbp
0
116
Member Avatar for elsiekins

I just checked [URL="http://www.cplusplus.com/reference/stl/vector/"]the documentation for the vector class[/URL] and it appears that <vector> does not offer an overloaded += operator. It seems that only the = assignment and [ ] subscript operators are offered. It looks as though you are trying to push char type variables into your vector. …

Member Avatar for elsiekins
0
145
Member Avatar for yatman

Consider usage of the [URL="http://www.cplusplus.com/reference/iostream/istream/tellg/"]tellg() [/URL]and [URL="http://www.cplusplus.com/reference/iostream/istream/seekg/"]seekg() [/URL]functions.

Member Avatar for Clinton Portis
0
65
Member Avatar for rhn94

I'll make you a deal... you translate and repost your request for help into pig latin.. and I'll throw some quality c++ code your way.

Member Avatar for rhn94
0
738
Member Avatar for NMAZ

This is really a self explanitory type of assignment. Straight-forward, no exotic techniques required. I will assume since requirement #3 mandates the use of PEMDOS precidence, requirements #1 & #2 do not; therefore, we can get away with working "left-to-right" for requirements #1 & #2. [U]Requirement #1[/U]: We have to …

Member Avatar for NMAZ
0
234
Member Avatar for Basteon

Although I am by no means an algorithms expert, I'll throw in my 2 cents anyway.. maybe I'll get lucky. In my opinion, I believe there may be a scope issue of the variables declared in line #5. The vectors are pass by value into perhaps a huge stack of …

Member Avatar for Basteon
0
1K
Member Avatar for sadsdw

Whenever you want white-space delimited data extraction from file, simply use ifstream's >> insertion operator... perfect for what you are trying to do: [CODE] while(infile >> temp) { myvec.push_back(temp); infile >> temp; myvec2.push_back(temp); infile >> temp; myvec3.push_back(temp); }[/CODE]

Member Avatar for sadsdw
0
190
Member Avatar for sharifyboy7

Just looking briefly over your code... there is one consideration that deserves special attention whenever you have a deque() type function; you should make special accomidations to ensure you will never dereferrence a NULL pointer, which I think may be the case here.

Member Avatar for Clinton Portis
0
150
Member Avatar for qvyhnl

[U]problem[/U]: you will always get zero because of line #6; you are exiting your function based soley on string sizes... [U]answer[/U]: one little tip on recursion that i found out on my own... Generally, for recursive functions, the return value of your function should also be a function parameter. any …

Member Avatar for Clinton Portis
0
103
Member Avatar for qvyhnl

suggestion: [code] //function prototype string unique_chars(string line, int index = 0);[/code] [code] //function definition string unique_chars(string line, int index) { int pos = 0; string temp; //recusive exit case if(index == line.size()) { return line; } pos = line.find(line[index], index+1) //if no other matching characters in string, move on to …

Member Avatar for Clinton Portis
0
186
Member Avatar for rutherfordln

Here is how you can compare an element, against every other element.. while we are at it, we'll erase any matching words in order to get a good word count: [code] string temp; //This array will contain single occurances of words from wordsM[ ] string unique_words[length]; //This array will serve …

Member Avatar for Clinton Portis
0
1K
Member Avatar for suncica2222
Member Avatar for elsiekins

you could use a technique called 'pointer arithmetic' to access ye' array: [CODE] #include<cstring> //dynamic array char* array = new char[11]; //breaking into the ol' C library to handle the array cstring strcpy(array, "I Love C++"); //display the array using pointer arithmetic method: while(array != NULL) { cout << *array; …

Member Avatar for Ancient Dragon
0
130
Member Avatar for ChristinaS

Hello Ms. Christina, Let me first say that I have never done any work with .pgm files. I've just looked at some .pgm examples though, and it doesn't look too terribly difficult. However, I think we might have to put our brains together to come up with the result that …

Member Avatar for Clinton Portis
0
206
Member Avatar for ajireland

You declared a single pointer, to a single SavingsAccount object. I believe what ye' wanted to do is to create a pointer to an array of SavingsAccount pointers; each element containing the address to a new SavingsAccount object: [CODE] //Pointer-to-pointer (or an array of pointers) SavingsAccount** accounts = new SavingsAccount*[100]; …

Member Avatar for mitrmkar
0
240
Member Avatar for scoob

1) create an array of struct objects that will hold ID and GPA information: [CODE] struct Student { int id; double gpa; }data[50];[/CODE] 2) Now you can fill up your array of structs: [CODE] int size=0; while(infile >> data[size].id) { infile >> data[size].gpa; size++; }[/CODE] 3) Now ye' can sort: …

Member Avatar for scoob
0
231
Member Avatar for ak47kumar1

there seems to be one major problem with your code.... [B]*** IT'S IN C ***[/B] (try posting your problem on the C forum, not c++)

Member Avatar for ravenous
0
114
Member Avatar for SabinIvy

I'd probably do somethin' like this here: [CODE] #include<iomanip> int spaces = 0; for(int i=30; i>0; i--) { cout << setw(spaces); for(int j=0; j<i; j++) { cout << '*' << endl; { spaces++; } spaces -= 2; for(int i=2; i<30; i++) { cout << setw(spaces); for(int j=0; j<i; j++) { …

Member Avatar for Clinton Portis
0
224
Member Avatar for ScreamingPsycho

I would suspect the letterDisplay cstring doesn't have anything in it. I think I can fix your problem without even having to double check your 'int to char' offset. Try this: [CODE] for(int i=0; i<26; i++) { letterDisplay[i] = 'A' + i; } letterDisplay[26] = '\0'; [/CODE]

Member Avatar for ScreamingPsycho
0
167
Member Avatar for anglwthnati2de

I believe you might have a problem with line #2. I just looked over the [URL="http://www.cplusplus.com/reference/stl/vector/vector/"]vector class constructors[/URL].. the only constructor with a single parameter takes a "reference to a vector" argument. In your code, you are attempting to pass an integer, which will probably throw a "could not convert …

Member Avatar for DarthMustard
0
119
Member Avatar for jmcorpse

Serious error on line #70. You are attempting to perform an assignment operation instead of a boolean comparison. Since you are using cstrings, I would recommend use of the [URL="http://www.cplusplus.com/reference/clibrary/cstring/strcmp/"]strcmp() [/URL]function from <cstring> [CODE] #include<cstring> for (int x = 0; x < size; x++) { if (strcmp(names[x], "Jim") == 0) …

Member Avatar for Agni
0
339
Member Avatar for z1ggy

My suggestions: You stated that you need to distribute hands to each player. I would recommend removing cards from deck() and pushing them into arrays assigned to each player; each array containing 5 Card objects. In order to determine what hand someone has, I would recommend making a function for …

Member Avatar for z1ggy
0
2K
Member Avatar for bflack

You got a few things to take care of which may or may not directly be related to your problem: 1. Please in the future, when you post on the forum, wrap your code with code tags. 2. void main() is bad, for many reasons. instead, use int main() which …

Member Avatar for WaltP
0
464
Member Avatar for penguins10

This is actually a clear-cut easy to follow assignment. Your instructor did all the thinking for you. There is nothing left up to your imagination; all you have to do is follow directions. [CODE] class Queue { public: Queue(); Queue(int& q); void add(int); void take(); private: int array[100]; }; [/code] …

Member Avatar for Zeeshan Cheema
0
244
Member Avatar for g_riding

The easiest way to read diagonally through your array would be to take the procedural approach and just write out each element of the 2d array that makes up the diagonal you want to add. But it seems like you are looking for a better method that would involve less …

Member Avatar for g_riding
0
452
Member Avatar for Ragster

The errors are self explanitory. Your sortArray() and binarySearch() functions are prototyped to take an array of cstrings, and you are trying to pass in a string object. couple of things to try: 1) see if you can pass in your string whilst calling the c_str() member [CODE] sortArray(name.c_str(), name.size()); …

Member Avatar for Ragster
0
710
Member Avatar for frogboy77

There might be a better way to do this, but this is just my idea: 1. determine sign of the result 2. make all cstring'd numbers positive 3. big number always goes on top 4. smaller number always goes on bottom 5. perform right-to-left subtraction just like you learned in …

Member Avatar for frogboy77
0
208
Member Avatar for Lorencodep
Member Avatar for Alkaline8214

click [URL="http://www.daniweb.com/forums/thread330100.html"]here[/URL] for a good example on recursion.

Member Avatar for Alkaline8214
0
272
Member Avatar for Revillio

try this: [CODE] for(int i=0, size=sV.size(); i<size; i++) { for(int j=0; j<size; j++) { if(sV[i].compare(sV[j]) == 0) { sV.erase(sV[j]); } } }[/CODE]

Member Avatar for Clinton Portis
0
1K
Member Avatar for Spiffy P Mcgee

1. How is the data arranged in your file? Please provide an example if that's not too much to ask. 2. A vector object can handle a file of infinite size and should be the container of choice for this project. Tell your instructor that a vector is an array. …

Member Avatar for Clinton Portis
0
276
Member Avatar for xCrusade

I just solved this problem like a couple weeks ago. [URL="http://www.daniweb.com/forums/thread327649.html"]Check out this thread[/URL]. I'm sure it will answer pretty much all your questions. Give this a shot on your own and see how you do. Then, if you have anymore questions let us know.

Member Avatar for Chris911
0
3K
Member Avatar for mommabear

[CODE] #include <iostream> #include <iomanip> #include <string> // User-defined headers #include "MediaCollection.h" using namespace std; // Global function definitions void DisplayMenu(); int main() { // Create my media collection MediaCollection MediaCollection; // Declare and initialize the variable used for the menu int menuChoice = 0; do{ cout << endl << …

Member Avatar for Clinton Portis
0
337
Member Avatar for Cqinzx

couple of ways you could do this, I will show you using a vector object, which will allow you to read in a file of any size. A vector has many of the same behaviors as an array so it's easy to use. [URL="http://www.cplusplus.com/reference/stl/vector/"]Here is a list of all the …

Member Avatar for Clinton Portis
0
217
Member Avatar for sadsdw

[code]str1 = "$#!%"; str1 += ' '; str1 += " the "; str1 += ' '; str1 += " police.";[/code]

Member Avatar for sadsdw
0
97
Member Avatar for Norzog

Here is a muy bueno tutorial on all the cool features of the dos console, to include changing colors: [url]http://www.adrianxw.dk/index.html[/url]

Member Avatar for Clinton Portis
0
91
Member Avatar for aviavyne

you could probably handle your modulus operation like this: [CODE] #include<cmath> class Number { public: Number(){x = 0.0;} Number(double a){x = a;} Number operator= (Number rhs); Number operator% (Number rhs); private: double x; }; friend ostream &operator<<(ostream &stream, Number n){stream << n.x; return stream;} Number Number::operator=(Number rhs) { x = …

Member Avatar for Clinton Portis
0
256
Member Avatar for qvyhnl

in your function, try the following at #17: [CODE] string temp1, temp2; while(getline(fin, temp1)) { //Handle even number of lines if(getline(fin, temp2)) { fout << temp2 << endl; fout << temp1 << endl; } //Handle odd number of lines else { fout << temp1; { }[/code]

Member Avatar for qvyhnl
0
413
Member Avatar for chubzyko

Just out of curiosity, how are you learning to code in c++ (ex: what method are you using, book, online tutorial, school professor...)

Member Avatar for Clinton Portis
0
135
Member Avatar for qvyhnl

1. if argc != 3, throw error message. exit program. 2. create an ifstream object that will handle all file reading operations. 3. create on ofstream object that will handle all file writing operations. 4. open the file using your ifstream object, using argv[0] as the file to open. 5. …

Member Avatar for qvyhnl
0
146
Member Avatar for chode1

This is a double post. You just posted the same question about an hour ago. You have identified that you have 2 different possibilities for file input: 1) Date, char, 4 digits, int. 2) Date, char, 4 digits, string, double, double. I would recommend reading in your file line at …

Member Avatar for Clinton Portis
0
80
Member Avatar for chode1

There are generally 2 different strategies for reading a file; read the file line-by-line (which preserves the white spaces) using getline() and then parse the line into the stuff you need, or read the file word at a time using the >> extraction operator, which is white space delimited.

Member Avatar for chiwawa10
0
98
Member Avatar for emko

Your request is very vague. I actually still have no clue what you are asking for. If I had to guess, you require a bar graph that will display in percent a user entry vs. proper zip-code format. For example, if a user enters 48$43-0020, 8 out of 9 characters …

Member Avatar for emko
0
127
Member Avatar for dlube

[CODE] //Begin loop: 0 to 40 (years) //Year_Total = Year_total + Monthly_payment * 12 //If the Loop_Counter / 2 has no remainder, then it has to be a "2nd Year" //Monthly_payment = Monthly_payment * 1.10 //End Loop[/CODE]

Member Avatar for smrati.katiyar
0
102
Member Avatar for GURU1349

You will never.. ever.. ever.. see an assignment operation take place in boolean if/else logic. The only things you will ever use for comparison are the following: <, >, >=, <=, ==, !, !=, && and ||. These are all you are allowed to use.. ever. No exceptions. Anything else …

Member Avatar for GURU1349
0
127
Member Avatar for knellgust

I think in lines #81 and #82 you have to use the -> dereferrence operator as opposed to the dot operator.

Member Avatar for knellgust
0
101

The End.