Hello, I've attempted to create program that will create a bar chart of stars to look like this...
--------------------------------------
1: ***
2: *
and so on, it has to read the amount of 6 numbers from the command line and then print the correct amount of stars for each, each time I try and compile this program i get the errors
1. ANSI C++ forbids comparison between pointer and integer
2. In Function 'int main ( int, char**)
I am very very new to c++ and these are errors I have never come across before, and frankly the program I have been asked to write is way out of my depth.
This is what I have written, whether it even does what i want it to i do not know, but I gave my best shot.Code:#include <iostream> #include <stdlib.h> #include <assert.h> using namespace std; void main ( int n, char c) /*int main (int argc, char* argv [])*/ { int n [6]; char c; int total = 0; if ( argc != 7 ) { cerr << "Usage: ./a.out n1 n2 n3 n4 n5 n6\n" ; exit(1) ; } while ( n < 6) { cin >> n [c]; c++; } for ( int i = 0; i < 6; i++) { n [i] = atoi ( argv [i+1]); assert (0 <= n [i] && n [i] <= 100); } for ( int i = 0; i < 6; i++) { total += n [i]; } cout <<"--------------------------------------------------/n" << total * c << "*"; }
any suggestions for why it keeps throwing up errors would be greatly appreciated.
thanks Karla.