I am having a bit of problem understanding why the compiler is shouting at me that I have an undeclared variable.
This bit of code works:
But this code gives me the following errors :Code:void line(int n, char c) { cout << callnumber << ": " ; for (int i = 0; i < n; i++) { cout << c ; } cout << endl ; }
barchart.cc: In function `void hyphen(int)':
barchart.cc:7: `i' undeclared (first use this function)
barchart.cc:7: (Each undeclared identifier is reported only once
barchart.cc:7: for each function it appears in.)
Code:void hyphen(int a) { for (i = 0; i < a; i++) { cout << "-" ; } cout << endl ; }



LinkBack URL
About LinkBacks


