Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <string.h>
- #define N 5
- #define M 5
- int n,m,i,j;
- int main()
- {
- int tab[N][M];
- srand (time(NULL));
- for (i=0; i<N; i++)
- {
- for (j=0;j<M;j++)
- {
- tab[i][j]=rand()%10;
- }
- }
- FILE *file;
- char nazwa [20];
- scanf ("%s", nazwa);
- file = fopen (nazwa, "w");
- if (file== NULL)
- {
- printf ("Nie udalo sie otworzyc pliku;\n");
- }
- else
- {
- for (int m=0; m<N; m++)
- {
- for ( n=0; n<M;n++)
- fprintf (file,"%d ",tab[m][n]);
- fprintf (file,"\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement