Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <mpi.h>
- #include <string.h>
- #include <stdlib.h>
- int main(int argc, char * argv[])
- {
- int noProcesses, processId;
- int ch = 0 ,c = 0, number_of_lines = 0; //number_of_lines = -1;
- static const char filename[] = "buu.txt";
- MPI_Init(&argc, &argv);
- MPI_Comm_size(MPI_COMM_WORLD, &noProcesses);
- MPI_Comm_rank(MPI_COMM_WORLD, &processId);
- FILE *file = fopen ( filename, "r" );
- int pocetriadkov = 0;
- if ( file != NULL )
- {
- char line [512]; /* or other suitable maximum line size */
- while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */
- {
- pocetriadkov++;
- }
- fclose ( file );
- printf("pocet riadkov suboru je: %d ", pocetriadkov);
- }
- else
- {
- perror ( filename ); /* why didn't the file open? */
- }
- MPI_Finalize();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement