+ 7
C++ throw variable
How can i throw a variable in c++? Because whenever i try to do this it gives me an error.
14 Réponses
+ 4
Have look at https://code.sololearn.com/cph9OWr5ZD0Y/?ref=app#cpp
Your code has several problems. I tryed to fix them.
Your initial problem was to detect the length of the array. In C and C++ this is not so easy. Normally you could put a sentinal value as last entry in the array. In my version, I use the value 0 which is implicit filled with for all not explicit initialized values. Other problems are wrong values used for indexes. In C the first element has index 0.
Finally you have to put the right amount of spaces before each line.
+ 9
Wow thank you all. I really appreciate it.
+ 7
I need a variable which is increasing every loop. But the for loop might occur error. There is probably a better way of doing this :/
+ 7
i already figured out how to get that variable. But there is another problem.
https://code.sololearn.com/cp543yXcBJXL/?ref=app
+ 6
Why would you need to do that?
+ 6
Hmm. I thought I asked that already. But it appears that the darn thing didn't work again because of the supposed no connection.
Anyways, just post the code you have even if it isn't done then we can help you.
+ 6
it gives four * and lots of spaces instead of a heart
+ 5
What is the new problem?
+ 5
Manuel, good, but it doesn't have spaces at the beginning of each line.
+ 3
Hi @Erik Isakov, usually is easier or better begining something new so I did something based on your code.
https://code.sololearn.com/crJfVEoZtSxB/#cpp
If it help you, please, tell me, if you need to do changes, change it and if you want to ask again, please, ask us.
+ 2
What code did you try? And what is your concrete behavior you like to expect?
+ 2
Exactly Manuel if Erik gives more detail maybe somebody can help him ;-)
+ 2
Yes of course. I think that is Erik's part. :) There are different ways to implement it. The easiest i think is to calculate the sum of all stars and spaces in the line and use this value to calculate the need spaces at the beginning of the line.
+ 2
You are not using some vars correctly. Im trying to do something