*EDIT
cout << "Enter number of integers: ";
cin >> arrray[row][col];
OUTPUT:
Enter number of integers: 1 2 3 4
Say user inputs 1 2 3 4
how can I count the number of integers the user inputed and send it back to the variable col inside the array to be the new column.
-The user inputed a total of 4 numbers
-So now i want to reinitalize during run time the value of col in the array[row][col]
(array[row][4]) for better understanding
Last edited on
Hi,
> I hope i have been pretty clear.
You haven't tried your best to make it clear.
What is the assignment question?
P.S : You may copy & and paste the assignment and show us the problem you are trying to solve.
Everybody here is glad to help when you get off the starting blocks :)
So to sum up :
+ Input the number of rows of the matrix
+ Create the matrix (rows == colums)
+ Input value for each matrix element
Am I right?
P.S : You shouldn't have removed your second post. We need it so that we can understand your problem better.
Definitely a case of obscure clarity but might we be looking at jagged arrays by any chance?
http://www.cplusplus.com/forum/beginner/192261/
Last edited on
for(int indexRow = 0; indexRow < ROW_SIZE; indexRow++)
{
cout << "Enter row " << indexRow << " for the 1st matrix: ";
for(int indexCol = 0; indexCol < COL_SIZE; indexCol++)
{
cin >> firstMatrix[indexRow][indexCol];
}
}
the main issue is initializing the array without a constant.
and i want to change the value of the array ROW and COL during run time.
But i get a compile time error because array must have CONST in [const][const]
right now i just have constant values for max col and mac row sizes.
I want to not use constant values and set the size of col and row by user input based on how many integers the user inputs on the first line
Last edited on
Do you use std::vector?
Have you learned pointers?
yes i have learned pointers
Pointer method is a little bit difficult. Do you want to use this more simple & lazy approach?
I want to use whatever approach i just want to know how to accomplish. Both ways maybe or what ever way yuoir willing to help me
Ive been playing with pointers and I cant seem to make it work so anything will help that will accomplish the task.
So before creating the matrix, the user has to input the number of rows & columns of the matrix?
This is the kind of thing im testing
const int ROW = 0;
const int COL = 0;
int *column;
column = (int*) (&COL);
*column = 2;
int array[ROW][*column];
for(int indexRow =0; indexRow < 2; indexRow++)
{
for(int indexCol =0; indexCol < *column; indexRow++)
{
cin >> array[indexRow][indexCol];
}
cout << endl;
}
i need to change value of constant first before i can do anything