why the use of File type is said undeclared?

This is a discussion on why the use of File type is said undeclared? within the C Programming forums, part of the General Programming Boards category; hi guys, i m a beginner for MPI programming. i m doing a program to open a file, however, there ...

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    1

    why the use of File type is said undeclared?

    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.

  2. #2
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    It's FILE
    C is case-sensitive.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Winsock problem
    By Wolf` in forum Windows Programming
    Replies: 1
    Last Post: 05-01-2010, 04:55 PM
  2. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 02:49 PM
  3. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  4. Script errors - bool unrecognized and struct issues
    By ulillillia in forum Windows Programming
    Replies: 10
    Last Post: 12-18-2006, 03:44 AM
  5. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21