1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

why the use of File type is said undeclared?

Discussion in 'C' started by rayda, Aug 31, 2010.

  1. rayda

    rayda New Member

    Joined:
    Aug 31, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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 
    #include 
    
    #include 
    #include 
    
    int main(int argc, char **argv)
    {
            int data[5][10];
            int i, j, x;
            int myid, numprocs;
            
            [COLOR=Red]File *fp;[/COLOR]
    
            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.
     

Share This Page