I'm pretty sure that isn't your code as you are compiling it, but just removing the extraneous
=""
rpodeces code that won't compile:
int display(int** a, int r,int c){
for(int i=0; i<r; i++){
for(int j="0;" j<c; j++){
cout << a[i][j] ' ';
}
endl;
}
int main(){
int rows,cols;
cols="4;
" string** array;
cout<<" hello a.r’s owner";
\n enter the number of rows : \t";
cin>>rows;
array = new string*[rows];
for(int i=0; i<rows; i++){
array[i]="new" string[cols];}
for(int i="0;" i<rows; i++){ {
cout<<" information "<<"( "<<i+1<<" )"<<"\n";
j="0;" j<cols; j++)
cin>> array[i][j];}}
display(array,rows,cols)
The
display
function is missing a terminating "}", it's
for
loop is badly formed, the
cout
is missing stuff, the
endl
is all on it's own ... and then we get to
main
which if just all over the place.
So I suspect that your actual code looks nothing like that, if it runs at all!
And then there is this:
Quote:
How do I convert a string to an int
As stated by Rick York,
C library function - atoi()[
^] will do it, but why are you reading integers as strings anyway?
cin
will read an integer perfectly happily.
Perhaps this will help:
Put values into an array from cin - C++ Forum[
^]