Computing.Net > Forums > Programming > C++ How to save calculated matrices

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

C++ How to save calculated matrices

Reply to Message Icon

Name: Daniel84
Date: November 20, 2005 at 04:16:36 Pacific
OS: Microsoft Visual studio.N
CPU/Ram: Windows
Comment:

I have written a program which calculates matrices. Now I want to use those calculated matrices. So I want my C++ programm to generate a file on my computer and to copy the calculated matrix to this new file. Does anybody know how to do this?



Sponsored Link
Ads by Google

Response Number 1
Name: Jerkstore
Date: November 21, 2005 at 19:29:24 Pacific
Reply:

Have you tried using a map of vectors?

map being your columns and the vector holding data for each column


0

Response Number 2
Name: sen (by santanusen_82)
Date: November 23, 2005 at 02:44:01 Pacific
Reply:

#include<stdio.h>

int mat[3][3] = {{1, 2, 3},
{4,5,6},{7,8,9}};


main()
{
int i, j;
mat2[3][3];

/*Write matrix to file*/
FILE *fp = fopen("matrix.txt", "w");
for(i=0; i<3; i++)
for(j=0;j<3; j++)
fprinf(fp, "%d\n", mat[i][j]);
fclose(fp);

/*Read matrix back from file*/
fp = fopen("matrix.txt", "r");
for(i=0; i<3; i++)
for(j=0;j<3; j++)
fscanf(fp, "%d", &mat2[i][j]);
fclose(fp);
}

Santanu Sen
National Institute of Technology
Durgapur
India


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: C++ How to save calculated matrices

how to save wmv file with ? www.computing.net/answers/programming/how-to-save-wmv-file-with-/14701.html

how to programm in C++ (for null le www.computing.net/answers/programming/how-to-programm-in-c-for-null-le/12576.html

C/C++How to find gard drive speed in RPM www.computing.net/answers/programming/cchow-to-find-gard-drive-speed-in-rpm/1704.html