visual studio 2010 erroes C2601 and C1075

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alice11
    New Member
    • May 2012
    • 3

    visual studio 2010 erroes C2601 and C1075

    i have some problems with this code i keep getting the error C2601: local function definitions are illegal.what i do wrong??

    Code:
    #include<stdio.h>
    #include<stdlib.h>
    
    int col;
    int row; 
    int i;
    int count;
    char Area[99][99];
    
    
    int main()
    {
    	void SetField()
    	{
    	  do 
    	   {
    		 printf("enter colmn");
    		 scanf("%d",&col);
    		 printf("enter row");
    		 scanf("%d",&row);
    		 printf("to exit enter colmn and row -999");
    	    }
    	  while((col!=-999)&&(row!=-999));
    	
    	}
    
    	void KillNieghbors(int g,int c)
    	  {
    		for(i=0;i<100;i++)
    			for(j=0;j<100;j++)
    			{ 
    				count=0;
    				while(int count<4)
    				 {
                         count++;
    				 }
    
    			  if(count<3)
                     { 
    					 Killneighbor(i,j);
    			     }
    			}
    
    			void PrintField()
    			 {
    				 for(i=0;i<100;i++)
    				     for(j=0;j<100;j++)
    				 {
                         printf("c%",&Aria[i][j]);
    
    				 }
    					 
    			 }
    	
           }
    }


    Error error C1075: end of file found before the left brace '{' at ...69

    Error 1 error C2601: 'SetField' : local function definitions are illegal 17

    Error 2 error C2601: 'KillNieghbors' : local function definitions are illegal 31
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    You can't do this:
    Code:
    int main()
     12. {
     [I]13.     void SetField()
     14.     {
     15.       do 
     16.        {
     17.          printf("enter colmn");
     18.          scanf("%d",&col);
     19.          printf("enter row");
     20.          scanf("%d",&row);
     21.          printf("to exit enter colmn and row -999");
     22.         }
     23.       while((col!=-999)&&(row!=-999));
     24. 
     25.     }
    [/I]
    etc...
    Functions must be defined outside of any other function.

    This has been done in other places in our code.

    Comment

    • alice11
      New Member
      • May 2012
      • 3

      #3
      tank you'but i dont understand what the problem is

      here:
      Code:
      void SetField()
      	{//this is underlined in red
      	  do 
      	   {
      		 printf("enter colmn");
      		 scanf("%d",&col);
      		 printf("enter row");
      		 scanf("%d",&row);
      		 printf("to exit enter colmn and row -999");
      	    }
      	  while((col!=-999)&&(row!=-999));
      	
      	}
      there is not a declaretion of another function in this func.
      now it givs me :IntelliSense: expected a ';' 17
      Code:
      
      #include<stdio.h>
      #include<stdlib.h>
      
      int Width=99;
      int Height=99;
      int col;
      int row; 
      int i;
      int count;
      char Area[99][99];
      
      
      
      int main()
      {
      	void SetField()
      	{//problem is in this line
      	  do 
      	   {
      		 printf("enter colmn");
      		 scanf("%d",&col);
      		 printf("enter row");
      		 scanf("%d",&row);
      		 printf("to exit enter colmn and row -999");
      	    }
      	  while((col!=-999)&&(row!=-999));
      	
      	}
      
      	void KillNieghbors(int row,int col)
      	  {
      		for(i=0;i<100;i++)
      			for(j=0;j<100;j++)
      			{ 
      				count=0;
      				while(count<4)
      				 {
                           count++;
      				 }
      
      			  if(count<3)
                       { 
      					 KillNieghbors(int g,int c);
      			     }
      			}
      	}
      			void PrintField()
      			 {
      				 for(i=0;i<100;i++)
      				     for(j=0;j<100;j++)
      				 {
                           printf("c%",&Aria[i][j]);
      
      				 }
      					 
      			 }
      	
             }

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        If SetFisld is a function then you call it main() this way:

        Code:
        int main()
        {
            SetField();
        }
        The code for this function:
        Code:
        void SetField()
              {
               do 
                {
                  printf("enter colmn");
                  scanf("%d",&col);
                  printf("enter row");
                  scanf("%d",&row);
                  printf("to exit enter colmn and row -999");
                 }
               while((col!=-999)&&(row!=-999));
         
             }
        cannot be inside main() or any other function.

        Comment

        Working...