1,426 Posted Topics

Member Avatar for asaidi

If you want to retain what was held in the vector then before you exit your program you must write that information to a file. Then you also have to change your code so that when the program loads it loads the file into memory. Files are the only way …

Member Avatar for asaidi
0
117
Member Avatar for arezooabyaneh
Member Avatar for Lawrence Motshegetsi
Member Avatar for lehlohonolo.mohaila

What do you need help with? What code do you have so far? If "help me please" is slang for "give me code" then you will find no one is going to "help" you.

Member Avatar for happygeek
-1
393
Member Avatar for sris20013

`char const*` should be `const char*`. May I ask why do you want to hold a constant string?

Member Avatar for Jamblaster
0
132
Member Avatar for Vikash_3
Member Avatar for daino

Have you ever used [getline()](http://www.cplusplus.com/reference/istream/istream/getline/)? you would have to use a `char*` but it should work nicely.

Member Avatar for daino
0
220
Member Avatar for cambalinho

You dont want to use magic numbers. You want to use the constants that are supplied.

Member Avatar for cambalinho
0
176
Member Avatar for Ng

Well what is the best score? Is it closest without going over? Is it just the closest guess? Are you trying to see how many attemps it takes to find the random number? Once you know exactly what you want then you can start writing code.

Member Avatar for Jamblaster
0
228
Member Avatar for Jun Bryan

> Don't give tips because my mind burnt out on studying functions, just give the code directly as I only need a very simple program. Thank you. You will find that most people here wont go for that. I will also take it from the code you posted that you …

Member Avatar for Ancient Dragon
-1
139
Member Avatar for VUEKID

Change `for_each(newLines.begin(), newLines.end(), [](std::string& s){ reverse(s.begin(), s.end()); });` to `for_each(newLines.begin(), newLines.end(), [](std::string& s){ reverse(s.begin(), s.begin() + 10); });` to only do the first 10 characters. I assume newLines is of type `std::vector<std::string>`.

Member Avatar for tinstaafl
0
180
Member Avatar for passant.elwasimy

So what is the problem you are having? No one is going to do this for you.

Member Avatar for ddanbe
0
70
Member Avatar for priyanka.choudhary.90038

A reference is a constant pointer in the sense that the reference cant be changed to point to something else. You can still change the value that reference points to. On the other hand if you pass a const reference then you cant change the value that the reference holds.

Member Avatar for deceptikon
0
1K
Member Avatar for prakhar_1

Did you write this code? Besides the fact that there is no formating and it is mostly not standard compliant what is the issue?

Member Avatar for NathanOliver
0
155
Member Avatar for vdhyasri
Member Avatar for Shinedevil

you could use a simple for loop in your main function and do a brute force method like your functions do or you could use the Sieve of Eratosthenes method which works very well. [url]http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes[/url] also on line 13 in your code you are using or which is incorrect in …

Member Avatar for Mahfuz_1
0
399
Member Avatar for owen99

for a set of random letters like only vowels you can create an array that holds the vowels and then use rand % (size of array) to get the index for the element in the vowel array.

Member Avatar for Anilorap
0
1K
Member Avatar for acmarshall

you need to put lines 35 and 36 inside the do while loop. Also dont use `void main()`. In the c++ standard it says that main returns an int.

Member Avatar for HiHe
0
10K
Member Avatar for Robin_3
Member Avatar for Ancient Dragon
0
491
Member Avatar for New In C++

We do not do your homework for you. What have you done so far? If you are having a problem with something that is one thing. To ask for us to do it for you is completly different.

Member Avatar for ikel
-1
107
Member Avatar for thomasbeecher

This is a classic case of stream corruption. You asked for a number and got a letter so after that all stream operations will fail. one way to stop this is to use a loop when asking for inputs. here is an example: int num; do { cout << "Enter …

Member Avatar for NathanOliver
0
761
Member Avatar for sarah.mathieson.7

Well the intrest rate and term should be members of the class so you can use them in mutiple functions.

Member Avatar for sarah.mathieson.7
0
239
Member Avatar for fashxfreak

You need to do the work. We will not do it for you. What code have you written so far?

Member Avatar for fashxfreak
0
688
Member Avatar for Brian1983
Member Avatar for sportguy98

Well the problem you are having is you are not doing what the assignment asks. When you add to the letter if you exceed the bounds of the character set you need to wrap around to the beginning. You also don't want to modify anything that isn't a character. All …

Member Avatar for ddanbe
0
192
Member Avatar for abhig

So what do you need? Can you assume what a college student is and what you need to have for members and functions?

Member Avatar for abhig
0
291
Member Avatar for nitin1

Well if the map is set up like this: map<"user-id", map<"movie-id", "rating"> Then if you want to see how many movies a person has rated you could do this: std::map<int, map<int, int> > m; // add stuff to m int numberOfMoviesRated = m["some-user-id"].size(); In the above example the call to …

Member Avatar for NathanOliver
0
979
Member Avatar for toneranger

Did you check to see if prices had anything in it? What happenes if you put this after line 17 and before line 18? if(prices.size() < 2) cout << "Vector size less than 2!" << endl else cout << "Vector has 2 or more elements!" << endl

Member Avatar for toneranger
0
309
Member Avatar for Sam R.
Member Avatar for NathanOliver
0
1K
Member Avatar for filipgothic

I would think they are just looking for big O notation since they give no size for n.

Member Avatar for filipgothic
0
264
Member Avatar for iana.bancila
Member Avatar for NathanOliver
0
207
Member Avatar for kingkong123

You could write your display like this for (int i = 0; destination[i][0] != '\0'; i++) cout << destination[i] << " ";

Member Avatar for Ancient Dragon
0
314
Member Avatar for SpottyBlue

Your call to srand should be outside your loop. I would suggest putting it on line 15. As for you call to rand() it should look like this: `r_number = rand() % 12 + 1;`. Your if condition on line 55 is also incorrect. Can a number be less than …

Member Avatar for kal_crazy
0
477
Member Avatar for nitin1

You start with a = 3. So line 2 will print a which is 3 then a gets incremented to 4. then it prints the space. Then a gets incremented to 5 then a which is 5 gets printed agian. This has to do with how the post and pre …

Member Avatar for vijayan121
-1
219
Member Avatar for NathanOliver

I was reading some articles on cplusplus.com and for kicks I read the template tutorial. At the very end of the section there is this paragraph: Since no code is generated until a template is instantiated when required, compilers are prepared to allow the inclusion more than once of the …

Member Avatar for vijayan121
0
163
Member Avatar for vishalonne

What is the code you are using to display the diagonals? You basiclly need to invert the display logic to have it display the non diagonals. As an FYI this is how I would display the diagonals // this assumes the array is sqaure and size is the size of …

Member Avatar for vishalonne
0
215
Member Avatar for ScienceNerd

this code will solve only this problem and will do it in 36 iterations. just did it for giggles to see if i could. if you want a generic code then you will have to do other things ;) [code=c++] #include <iostream> #include <stdlib.h> using namespace std; int main() { …

Member Avatar for casey.cole.12576
0
2K
Member Avatar for nikzer

@ nitin1 std is a namespace that all of the standard c++ functions and classes are in. A namespace is just another level of orginizing your code. You can equate it to the file cabinet metaphor. The function is a piece of paper. The file the function is in is …

Member Avatar for NathanOliver
0
219
Member Avatar for torrm

The way I would do this is to read in all of the questions into an array. After that then shuffle the array around. Here is a little example std::string questions[15]; // load the questions into questions[] srand(time(NULL)); // this seeds rand int randIndex; for (int i = 0; i …

Member Avatar for rubberman
0
160
Member Avatar for laavanya

Don't forget that you will need to add the counter increment to the copy constructor and the assignment operator. You probobly want to have that as a seperate counter since those objects will be implicitly created.

Member Avatar for laavanya
0
2K
Member Avatar for Dani
Member Avatar for Dani
0
2K
Member Avatar for titas.datta

Well one way to fix that is to see what is bigger and if the number that is being subtracted is larger than the number it is being subtracted from switch them around. Then do your normal subtraction and add a "-" to the result. `10 - 100 = -90` …

Member Avatar for Ketsuekiame
0
408
Member Avatar for cedwards

First off your coveredarray should be of type char not int. Secondly what I would do is load guessarray with the numbers 1-9 in order. Then I would go through the array and swap the element of the current index with one that is randomly generated. To do that take …

Member Avatar for cedwards
0
201
Member Avatar for tanatos.daniel

Well in the warning you got it says the file name can't be "aux" and you are using that. Try chnaging the name of your file to something else.

Member Avatar for tanatos.daniel
0
368
Member Avatar for sireiz

Do you know the STL? If not check [this](http://www.cplusplus.com/reference/) out.

Member Avatar for sireiz
0
266
Member Avatar for new_developer

I know microsoft uses -1 as true if you are using access so it makes sense that they are doing that with there compiler. AFIK any value other than 0 is considered true and I havent seen a case where that doesnt work.

Member Avatar for Ancient Dragon
0
220
Member Avatar for irtza

The code in your first piece of code should not compile. More than likely there is some sort of compiler extension taking care of it for you. What compiler are you using? Static arrays can only be initialized with a const size argument.

Member Avatar for vijayan121
0
4K
Member Avatar for ktsangop

Just as an FYI. If you call erase on a vector and you are using iterators any iterator that is after the begining will be invalidated.

Member Avatar for ktsangop
0
6K
Member Avatar for nchy13

a const function can be called by a non const function. a const function can only call other const functions. the same thing applies to objects as well.

Member Avatar for NathanOliver
0
961
Member Avatar for Subhadeep_1

I would suggest using something other than graphics.h. it is not supported by any modern compilers and it will only work in a dos enviroment.

Member Avatar for Subhadeep_1
0
498

The End.