1,288 Posted Topics

Member Avatar for princessophia

#include <string> ... ... string user_input; cin >> user_input; and since you are compelled to use a c-string for your function, char* c_string = user_input.c_str();

Member Avatar for Assembly Guy
0
255
Member Avatar for Learner010

Pointers can be explained pretty fully in just a couple of sides of paper. A whole book on them would be enormous overkill. They are very simple. The problems with them tend to come when people try to explain them with bad metaphors involving streets and house numbers, or envelopes …

Member Avatar for Learner010
0
310
Member Avatar for Ahsanali1603
Member Avatar for prikshit.choudhary.12
Member Avatar for daniel1977

> I am unable to link or locate the folder #include. \#include isn't a folder. It's an instruction to the pre-processor to find the file you specify right after \#include and copy it in. There is no folder named "\#include" > If I can't resolve this problem can I use …

Member Avatar for mike_2000_17
0
153
Member Avatar for kruschev

We call the function f(5). What does f(5) return? It returns 2 \* f(4). What does f(4) return? It returns 2 \* f(3), so let's put that back into "what does f(5) return?" What does f(5) return? It returns 2 \* f(4) = 2 \* 2 \* f(3) So what …

Member Avatar for kruschev
0
216
Member Avatar for new_developer

> why we can't check if array is not initialized. How can you tell the difference between a byte that has been "initialised" and a byte that has not been "initialised", just by looking at the byte? It's meaningless.

Member Avatar for deceptikon
0
1K
Member Avatar for saja.omarii.7

What are you struggling with? How far have you got? Do you understand how to actually do this? By which I mean, can you tell me which of these two words is a palindrome: CATFISH CIVIC

Member Avatar for Jamblaster
0
338
Member Avatar for skyyadav
Member Avatar for gerard4143
0
322
Member Avatar for cambalinho

What are you trying to do? Tell us what you want the macro to transform this `events2( b) a;` into.

Member Avatar for Ancient Dragon
0
224
Member Avatar for Ahsanali1603

http://stackoverflow.com/questions/982659/quickly-create-large-file-on-a-windows-system

Member Avatar for Moschops
0
390
Member Avatar for Prithvi.R.K

Do you know how to do this on paper? If you simply write down the steps of how to do this on paper, the code version will be obvious.

Member Avatar for Moschops
0
73
Member Avatar for christinetom
Member Avatar for 9tontruck

The base class' constructor and destructor are private, so an inherited class can't call them. Which is bad.

Member Avatar for Moschops
0
205
Member Avatar for foxhatxd

How do you know what the values of i and j are to give us the example? Please sghow us the actual code that produced that actual output.

Member Avatar for foxhatxd
0
167
Member Avatar for PulsarScript
Member Avatar for johnson_2

> whereas my sorting for X seems be to sorting correctly. I don't think it is. Your program suggests that -999 is greater than -9, which isn't true; -999 is nine hundred and ninety less than -9. Flip round the `<` and the `>` on all your sort functions.

Member Avatar for johnson_2
0
665
Member Avatar for azwitsal
Member Avatar for SpottyBlue

> The EnterExpense() function only creates one line instead of many (if the user wants to continue entering more info). Because you reopen the output file every time you go round the loop. Open it once before the loop, close it once afterwards.

Member Avatar for richieking
0
279
Member Avatar for vladimir.bednoi

Spot the difference time: `«` vs `<<` `»` vs `>>` The one on the left is not C++ code. The one on the right is. This is what happens when you copy and paste code.

Member Avatar for Moschops
0
277
Member Avatar for sing1006

`sum/6` is an int divided by an int. An int divided by an int will give you back an int, always. What's 3/2? 1. What's 29/6? 4. To get a double answer, you need one of the two values to be a double. An easy way to do this is …

Member Avatar for Moschops
0
187
Member Avatar for idnurr

Each set locks a mutex, then changes the variable, then unlocks the mutex. Make sure the struct's internal variables are private so only the set function can change them.

Member Avatar for rubberman
0
133
Member Avatar for smdjilani

To add to what has been said, I see this most commonly when writing code for embedded hardware, in which some physical real world sensor or signaller is permanently linked to a specific memory address. For example, if you look in the manual for your embedded hardware and see that …

Member Avatar for Ancient Dragon
0
171
Member Avatar for PulsarScript

You need your loop to contain two different sets of behaviour. One for when i is 1-3 and 7-9, and one for when it is 4-6.

Member Avatar for darkfire3133
0
193
Member Avatar for kbear23

> For this sets of code below, how do I write such that 4 sets of x,y coordinates will be stored in ShapeTwoD? This doesn't store them with pointers. It just stores an array of four points. Does it have to use pointers? struct point{ int x; int y; }; …

Member Avatar for kbear23
0
2K
Member Avatar for VBOI

Because your compiler thinks using ctime is *such* a bad, *bad* idea that it's not going to let you do it unless you specifially tell it to let you.

Member Avatar for deceptikon
0
2K
Member Avatar for coiseng

You cannot store different types in a vector. However, if all your class objects are of the same base class, they are all objects of that base class, so you can store in the vector a pointer-to-base-class; each pointer in the vector pointing to an instance of your objects. vector<ShapeTwoD*> …

Member Avatar for Moschops
0
477
Member Avatar for Landoro

A std::vector or std::array spring to mind. vector<Body> theVector; // make a new Body object here theVector.push_back(newBodyObject); Use push_back to keep adding them.

Member Avatar for Moschops
0
463
Member Avatar for DawnofanewEra

You have hard-coded the size of your arrays: `int c[5][5],d[24],p[24][6],list[5],r;` If you need arrays that can have their size set at runtime, don't use arrays. Use C++ std::vector (or the shiny new std::array if your compiler supports it) to get arrays that you can set the size of at runtime.

Member Avatar for tinstaafl
0
1K
Member Avatar for tbuchli
Member Avatar for tensity

Take your value. Check it will fit in the range (so in the example above, if your value is less than 1 or grater than 3, stop now). So now you need to know how far along the range your value is. The maximum value along the range in the …

Member Avatar for tensity
0
449
Member Avatar for vyalineconstantino

If I understand what you're saying, your problem is that when you generate random numbers, sometimes you generate a number you have already used? So keep a record of all the numbers already used, and when you generate one, only use it if you haven't already used that number.

Member Avatar for Moschops
0
2K
Member Avatar for skyyadav
Member Avatar for can-mohan
Member Avatar for renagadejesus

Here's a start. I suggest you add the headers and using declarations that are needed, get it running, and then move on to the next step - outputting a list of them. int main() { string titleArray[10]; string authorArray[10]; double priceArray[10]; for (int i=0; i<10; ++i) { cout << "Title …

Member Avatar for Moschops
0
269
Member Avatar for highonbikes

The function advanceDate does not touch the appointment object you are passing into it. You are making a copy named newApp2 (like this - `appointment newApp2(e);`), altering the copy, outputting something from the copy, and then returning the copy (which is promptly thrown away). If you want to change the …

Member Avatar for Moschops
0
155
Member Avatar for glao

The simple, forward-Euler method works as follows: 1) Get current value of the variable you care about. 2) Get rate-of-change of the variable. 3) Next value is current_value + (rate_of_change \* time_step) Repeat until you've gone forwards enough in time. So in this case, it looks like the time_step is …

Member Avatar for glao
0
656
Member Avatar for nathan.pavlovsky
Member Avatar for Andy_3
Member Avatar for princess.ferolino.1
Member Avatar for cambalinho
0
248
Member Avatar for Tewhano

Firstly, you have eight menuItems to read, and eight menuPrices, so you should be making an array of size 8 rather than 7. Otherwise, nothing here that should stop your code working. If I had to guess, your file `menu.txt` is not in the same directory that the executable is …

Member Avatar for Tewhano
0
134
Member Avatar for SolidSora

The logic of your code is wrong. It is not an infinite loop but you are going to print out a lot more than you meant to. What happens at the moment when, for example, i = 40 and j = 30?

Member Avatar for Mahfuz_1
0
320
Member Avatar for Saurav Akolia
Member Avatar for iamcreasy

That code doesn't compile, and even if it did it probably wouldn't throw an exception. If you were very lucky, you'd get a segFault, but probably not. If your code throws an exception, and you think you can deal with it and carry on, catch it. What exception are you …

Member Avatar for deceptikon
0
438
Member Avatar for rock123
Member Avatar for Moschops
0
58
Member Avatar for Garidius

It would be worth your time, at this point, to take a step back and decide what you want to do. You have currently chosen to attempt writing GUIs using the Win32 API. Let's go back a step. On a modern OS, you cannot directly change the value of a …

Member Avatar for Garidius
0
551
Member Avatar for new_developer

What Deceptikon is saying is, for example, what happens if the user has to type '10'? You'll read the first input and think the user meant '1' Anyway, that aside, you don't need an int. Just compare against the *char*. For example, if the user enters the char '1', `if(no …

Member Avatar for Moschops
0
187
Member Avatar for princessophia

I see your loop has a return in it. This means that the loop ends the very first time. Put the return *after* the loop. You're also using the variable that tells you how many years to run for (the user input) as the variable telling you how many years …

Member Avatar for Moschops
0
197
Member Avatar for Danja

`//char *cmdStr = command.c_str;` c_str() is a function. It is called like this: `char *cmdStr = command.c_str();` Second issue: The bit at the end looks like a a definition of a class function. Presumably you're not trying to define a class function; you're trying to *use* a function. In C++, …

Member Avatar for Moschops
0
565
Member Avatar for mohammed.alrasheed.353

The End.