1,426 Posted Topics

Member Avatar for atticusr5

to sort the list using sort you would have to do [code=c++] sort(theList.first(), theList.end(), compareFunction); [/code] the compareFunction is one that you would have to write to compare the avg of one object to the avg of another object. [URL="http://www.cplusplus.com/reference/algorithm/sort/"]this[/URL] should help you out.

Member Avatar for atticusr5
0
147
Member Avatar for Lokril

The modulo operator simple finds what the remainder is after dividing by a number. So with integer division 20 / 3 = 6 but 6 * 3 = 18 so there has to be a remainder of 2. you get the remainder by subtracting the divisor times the answer from …

Member Avatar for jonsca
0
144
Member Avatar for frank731tr

you should have the input be read in as a sting and test if it is empty. if it is then quit and if it is not then continue.

Member Avatar for mrnutty
0
2K
Member Avatar for holocron

what is the & for in [icode]DLSortedList * newList = new DLSortedList(dlSL&)[/icode]? i think you might want to be doing [icode]DLSortedList * newList = new DLSortedList(&dlSL)[/icode]

Member Avatar for holocron
0
243
Member Avatar for jackmaverick1
Member Avatar for koundinya
Member Avatar for NathanOliver

Hey All, I just finished my code and it seams to work fine. I'm looking for advice on improving it or making it easier to understand. Its not Fully complete because I only have to set up to take in a number less than 2147483648 because i am using an …

Member Avatar for vijayan121
0
167
Member Avatar for l1nuxuser

[URL="http://www.functionx.com/cpp/articles/filestreaming.htm"]here[/URL] you go.

Member Avatar for jonsca
0
90
Member Avatar for lochnessmonster
Member Avatar for mrnutty
0
61
Member Avatar for bensewards

well if you have the read the data in from the file. store the names into an array of a string and the gpa into an array of doubles. I'm not exactly how you are supposed to be sorting the information. the trick is that when you are sorting one …

Member Avatar for ravenous
0
1K
Member Avatar for CD1

You are right to assume that there will be some code to write but its not that much. If you are going from a five hundred and fifty to 550 needs 3 tables. If you can use the STL than using a map you would be a great way to …

Member Avatar for CD1
0
82
Member Avatar for MasterGberry
Member Avatar for Wej00

I would have to say that using global variables should not be used. IMHO all variables should either be in a function like main or in a class. It looks cleaner and is better understood if you pass a variable to a function instead of making it global and just …

Member Avatar for Banfa
0
1K
Member Avatar for lochnessmonster

if you are trying to be really efficient with the amount of ram you are using and you need a variable that would hold anything from -10 to 10 then a singed char would work and you are only using 1 byte of memory.

Member Avatar for NathanOliver
0
118
Member Avatar for Vindal

Setting you variables to zero on lines 85 and 103 isn't what you should do. You should initialize them to the first value in the array and then check from there. On line 89 you are checking if the lowest temp is less than the array value and if it …

Member Avatar for WaltP
0
579
Member Avatar for ffmwheeler

What do you mean saying its no longer random? Are you getting the same results each time?

Member Avatar for ffmwheeler
0
117
Member Avatar for newbee3

if you are asking how to ask for a password then just ask for it inside the while loop. Replace [icode]password = "abc123";[/icode] with code to ask the user for there password and then retrieve the password.

Member Avatar for chiwawa10
0
110
Member Avatar for format_c

why are you putting a conditional inside the array index? [code=c++] if (paths[sROW][sCOL]==' ' && paths[sROW+1<=19 /*this doesn't make sense*/][sCOL] [/code]

Member Avatar for VernonDozier
0
101
Member Avatar for mhaviv

I know this isn't a solution but it should help. If you know that when using your function trying to calculate a factorial higher than 31 will be incorrect, then you can use an if statement to check the number supplied to the function to see if it is higher …

Member Avatar for NathanOliver
0
92
Member Avatar for knellgust

Line 7 should be [code=c++] void Initialize(Book[], int); [/code] And line 26 should be [code=c++] void Initialize(Book arrbook[],int size) [/code]

Member Avatar for knellgust
0
167
Member Avatar for HBK_100
Member Avatar for jwill222

@ Nathaniel using a switch statement would be less than ideal in this case because you have a large range of numbers to work with. Even with fall through you would still need to have 60 cases.

Member Avatar for jwill222
0
4K
Member Avatar for SgtMe
Member Avatar for clown1342

did you try pulling the cmos battery for a few minutes and then put it back in then give it a boot?

Member Avatar for jaydeee
0
137
Member Avatar for brycematheson

To expand on what Gerard pointed out is when you pass an array to a function it actually only passes a pointer to the first element. Since you are working with pointers any change to a value in the array in a function is reflected in main. [code=c++] void foo(int[]); …

Member Avatar for arkoenig
0
97
Member Avatar for jordankaushik

are you using a loop to read the file and check it against your permuted word?

Member Avatar for jordankaushik
0
107
Member Avatar for frogboy77
Member Avatar for Bri426

You should be putting your if statement inside the while loop. The way the program should work is you should read in a city name and then check to see if that city matches or partially matches the city the user entered. If it does output the city name that …

Member Avatar for NathanOliver
0
193
Member Avatar for lauruskamj
Member Avatar for NathanOliver
0
100
Member Avatar for OPTIMUS999

Part of your problem is that your coding style is making it difficult to line parts of the code. The brackets don't always line up and that makes it difficult to find the mismatch. I would suggest you separate each function into its own header file so that you don't …

Member Avatar for NathanOliver
0
2K
Member Avatar for rtdunlap

first you need to have a return statement at the end of your mean function to return avg. Also your function prototype and your function definition don't match. Your prototype has a array and a int but you definition has no variables. [code=c++] float mean() { //... return avg; } …

Member Avatar for Tellalca
0
114
Member Avatar for Annettest
Member Avatar for chief427
0
770
Member Avatar for kra9853
Member Avatar for jonsca
0
79
Member Avatar for tKc

you cant because you are reading the file into an int. you will need to read it into a string and then test to see if has a decimal or not.

Member Avatar for NathanOliver
0
333
Member Avatar for ccube921

on lines 15 and 17 you are setting your counter variable to -1. when it tries to access element -1 it throws an error. try setting the variables to 0 and see what happens.

Member Avatar for NathanOliver
0
131
Member Avatar for Morbane

This is a nice conversion function at will convert any type that has an << operator. [code=c++] #include <string> #include <sstream> template<typename T> string ConvertToString(T & value) { std::stringstream ss; ss << value; return ss.str(); } [/code]

Member Avatar for Morbane
0
2K
Member Avatar for awadojag
Member Avatar for Fbody
0
101
Member Avatar for XodoX

since you dont know what the size of the file will be i would suggest using a container from the STL. that said i will use a vector for my example. [code=c++] vector<string> words; string word; ifstream fin("text.txt") // use ifstream object to get info from file while (fin >> …

Member Avatar for XodoX
0
168
Member Avatar for baconswife

on line 19 it should be [icode]if (found)[/icode]. the same applies to line 22. also why is found a bool? [EDIT] what are you trying to do with this [icode] found = 2 * a > b;[/icode]?

Member Avatar for Fbody
0
123
Member Avatar for emko

lines 19 through 22 are not actually doing anything. you need to get the words from the file in order to push them into the stack. To get the word from the file into your stack you will need to do something like this. [code=c++] stack<string> Stack; string word; ifstream …

Member Avatar for emko
0
112
Member Avatar for fukki

I would like to add that you should not be using void main. per the c++ standard main should always return a int.

Member Avatar for NathanOliver
0
119
Member Avatar for TinhornAdeniyi

all of your function definitions do not name the variables that you are passing to them. You are also declaring the variables that you are passing to your functions globally. You don't need to have any function parameters if you are only using global variables but I suspect that your …

Member Avatar for VernonDozier
0
196
Member Avatar for TayKaye

what happens if you change line 32 to [code=c++] double root = sqrt(double(number)) + 1; [/code] [EDIT] I think you might also want to recheck the way you are incrementing your test variable.

Member Avatar for caut_baia
0
151
Member Avatar for aravind rao

if you want to store the address of that element in you vector than you can do [code=c++] vector<int*> stack stack.push_back(&(array[1][1])) [/code] if you are trying to store the value of x and y values you can use a 2d vector like [code=c++] vector< vector<int> > stack vector<int> temp; if …

Member Avatar for aravind rao
0
178
Member Avatar for aviavyne

if you want to take data in as a string and convert it you can do: [code=c++] // you have to have these #include <strstream> #include <string> int number; std::string input; std::stringstream ss; cout << "enter number: "; getline(cin, input); ss << input; ss >> number; // now number is …

Member Avatar for NathanOliver
0
200
Member Avatar for BEG148

What are the errors you are getting? Also your addDay function is not right. it should accept an integer parameter and add that to the current day to get the new day.

Member Avatar for BEG148
0
1K
Member Avatar for GBoyle

Are you sure that ContactPtr is holding a BCorp and that it is getting cast right? Also why are you casting objects to a double * in you contact object.

Member Avatar for GBoyle
0
149
Member Avatar for asa88

i would use a char array for your input but rather a string [code=c++] string input; set<string> dictionary; // open file while(getline(nameFile, input)) // read untill there is nothing left to read { set.insert(input); // insert into set } // print contents [/code]

Member Avatar for NathanOliver
0
2K
Member Avatar for xiansen
Member Avatar for ToiNKieZ

The End.