|
storing an array
Can someone help me with my storing array problem. I have an array and i need to have MFC create a text file and save my array in that textfile but it must be saved in rows and columns like a matrix. I am doing my code in C++ and of course I am using MFC, also can someone tell me how to read in a matrix from an external file saved on my computer this way I can just read in the file and set it as my matrix_a. Here is my code for the matrix:
int matrix_a[10][10]={1,2,3,4,5,6,7,8,9,10,
11,12,13,14,15,16,17,18,19,20,
21,22,23,24,25,26,27,28,29,30,
31,32,33,34,35,36,37,38,39,40,
41,42,43,44,45,46,47,48,49,50,
51,52,53,54,55,56,57,58,59,60,
61,62,63,64,65,66,67,68,69,70,
71,72,73,74,75,76,77,78,79,80,
81,82,83,84,85,86,87,88,89,90,
91,92,93,94,95,96,97,98,99,100};
//PRINTS OUT MATRIX A
for (int i=0;i<rows_columns;i++)
{
for(int j=0;j<rows_columns;j++)
{
res.AppendFormat("%i ",matrix_a[i][j],"\n");
}
outputText.SetString(res);
UpdateData(0);
}
Last edited by JdS : 08-Oct-2004 at 05:00.
Reason: Please insert your example C/C++ codes between [c] and [/c] tags
|