+ 1

what is this 'initialiser' error in coding? (c++)

while in the coding, i get several errors as i try to compile. one particular error i get which always remains without solution in "expected initiliser before...". i've went back through the beginner part of the c++, and i cannot find a fix to this problem. help please? :(

8th Mar 2017, 2:56 AM
saiac smith
saiac smith - avatar
4 ответов
+ 2
probably missing a ; somewhere. theres nothin else lol. if you could post the code. here or as a code. I can confirm syntactically what is causing it
8th Mar 2017, 5:43 AM
Michael Szczepanski
Michael Szczepanski - avatar
+ 1
yeah..... unless you forgot when you put it in here... Every statement in c++ ends in a ; so int a; int b; int sum; **could also be written as int a, b, sum; **these should also be initialized to 0. int a = 0; ... the cin statements cin >> a; the only things that Usually dont have a ; aftern it in c++ are function or conditional bodies. if (test){ ... } // no ; here. just for statements. hope this helps!!
8th Mar 2017, 2:19 PM
Michael Szczepanski
Michael Szczepanski - avatar
0
"#include <iostream> using namespace std; int main() { int a int b int sum cout<<"input number to here"<<endl; cin>>a cout<<"input one other number"<<endl; cin>>b int sum=a+b cout<<"the output is:"<<sum<<endl; return 0; }"
8th Mar 2017, 10:02 AM
saiac smith
saiac smith - avatar
0
thank you! i constantly forget
8th Mar 2017, 2:41 PM
saiac smith
saiac smith - avatar