what is wrong with my code please help!!

Discussion in 'C' started by imported_compEng, Apr 30, 2011.

  1. imported_compEng

    imported_compEng New Member

    Apr 22, 2011
    Likes Received:
    Trophy Points:
    char pRead(int f)
    	FILE *fp;//local pointer of type file
    	int i;
    	char ch;
    	fp= fopen("mytest.txt", "r");
    	for (i = 0; (ch = getc(fp)) != EOF && i < 5; i++)
    		if (i==f) return ch;
    the error is :
    Error 2 error C2371: 'pRead' : redefinition; different basic types c:\protocolsc\p1.c 53

    suppose that the argument i sent(f) is from this code
    void sender1(void)
      frame s;	
      packet buffer;	
      char readArray[4];
       int i, j;
       for (j=0; j<5; j++)
                      readArray[j]= pRead(j);    //need to fill the array by calling pRead character by character
      while (true) {
    		for (i=0; i<=5; i++)
    			buffer.data[i]=readArray[i];    //need to fill the array that a read above in a buffer of typedef (typedef struct {unsigned char data[MAX_PKT];} packet;)

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice