+ 1

Expected initializer before '+=' token. SOLVED

I've tried to google this issue but all of the questions were involved with templates. I'm trying to create a ramp-like thingy out of hashtags, but this issue keeps popping up in line 13 where I'm trying to addition nL with itself. I'd appreciate any kind of help and thanks in advance! :) The following code is edited and is not the original script of this question. It has however been fixed and changed a little with help of this question. https://code.sololearn.com/chuO8mVf7hA6/?ref=app

10th Jul 2017, 8:48 AM
Mydris
Mydris - avatar
11 Answers
+ 6
https://code.sololearn.com/crBRMkBXv7tc/?ref=app you had already declared nl and symbol as global variables. by declaring them again locally it creates a different version. that version in your code has no value. thus the error re uninitialised
10th Jul 2017, 8:52 AM
jay
jay - avatar
+ 7
also you need to replace if(i=nL) by if(i==nL)?
10th Jul 2017, 8:55 AM
Karl T.
Karl T. - avatar
+ 6
Your code is strange, int nL += nL ? 😑 (not to mention, er wrong)
10th Jul 2017, 8:51 AM
Karl T.
Karl T. - avatar
+ 6
jay figured out what you wanted to do apparently 😂
10th Jul 2017, 8:54 AM
Karl T.
Karl T. - avatar
+ 5
Karl is correct i=nL is an accidental assignment
10th Jul 2017, 8:57 AM
jay
jay - avatar
+ 5
re emtpy boxes -> local declaration of char symbol.. overrides global char symbol.
10th Jul 2017, 8:58 AM
jay
jay - avatar
+ 5
here is a little article explaining the difference between local and global variables https://www.funprogramming.org/50-What-are-global-and-local-variables.html
10th Jul 2017, 9:05 AM
jay
jay - avatar
+ 1
Is that something you can't do?
10th Jul 2017, 8:52 AM
Mydris
Mydris - avatar
+ 1
Strange... I did that first but the output just came up with empty boxes. Thanks a lot though!
10th Jul 2017, 8:54 AM
Mydris
Mydris - avatar
+ 1
Oh ye, rookie mistake. Thanks. xP
10th Jul 2017, 8:56 AM
Mydris
Mydris - avatar
+ 1
Thanks for the hint, Jay. I didn't know that. :)
10th Jul 2017, 8:59 AM
Mydris
Mydris - avatar