hi guys, i m a beginner for MPI programming.
i m doing a program to open a file, however, there is error saying that 'File' undeclared. but I thought File is a type like int or char, isnt it?
below is my codes:
Code:
#include "mpi.h"
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char **argv)
{
int data[5][10];
int i, j, x;
int myid, numprocs;
File *fp;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &myid);
if(myid == 0)
{
if((fp=fopen("/home/rayda/pic_1.txt", "r")) == NULL)
{
printf("Cant open file\n");
exit(1);
}
for(i = 0; i < 5; i++)
{
for(j = 0; j < 10; j++)
{
x = fgetc(fp);
if(x == 49)
{
data[i][j] = 1;
}
else if(x == 48)
{
data[i][j] = 0;
}
else
{
j--;
}
}
}
for(i = 0; i < 5; i++)
{
for(j = 0; j < 10; j++)
{
printf("%d", data[i][j]);
}
printf("\n");
}
}
MPI_Finalize();
return 0;
}
i have been make the statement with error in red color. hopefully someone can tell me what's wrong with my code. thank you.