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 ];
}
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>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)
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?
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?
ASKER