Link to home
Start Free TrialLog in
Avatar of morales7_0
morales7_0

asked on

How to pass an array as a parameter to another function?

I have this function that reads one line from a text file.   The file is a list of tokens from a previous scanner program.  I need to classified the tokens into their catergories.  I can't figure out how to use the result from this function and pass it to the other function that compares the tokens and classifies them into their category.  Can anyone help me out.

char getToken()
{
   int SIZE = 40;
   char line[ SIZE ];
 
   if(( tokfile = fopen( "tokens.txt", "r" )) != NULL )
   {
      if( fgets( line, 40, tokfile ) == NULL )
         printf( "fgets error\n" );
      else
         printf( "%s", line );
   }
   
   return line[ SIZE ];

}
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of morales7_0
morales7_0

ASKER

Cool!!!  How would I compare the result from getToken() function with the list of categories in my tokenTable() function?    
>>with the list of categories in my tokenTable() function?

Sorry, but since I do not know that function, it is hard to give any advice on that :o)
You need to pass the address...

char getToken()
{
   int SIZE = 40;
   char line[ SIZE ];
 
   if(( tokfile = fopen( "tokens.txt", "r" )) != NULL )
   {
      if( fgets( &line, 40, tokfile ) == NULL )
         printf( "fgets error\n" );
      else
         printf( "%s", line );
   }
   
   return line[ SIZE ];
}

I do not know the point of returning line[SIZE] here either?