I'm better at C++ than C right now and I forgot how to use arrays in functions from main.
I want to do something like

void fileReader(infile[] );

. Is infile supposed to be a pointer and if so how is it written?

void fileReader(infile[] );

like void fileReader( char *infile ) ???

[Edit] That's the prototype of a function that accepts a string as parameter
fileReader( string ); is the actual call in main where string could be
char string[] or char *ptr_to_string = string; or char *string = "literal string";

void fileReader(infile[] );

like void fileReader( char *infile ) ???

Yes that would be what I want to do. How do I declare it and use it in both the main function and the void function?

Yes that would be what I want to do. How do I declare it and use it in both the main function and the void function?

void fileRead( char *s );

int main( void )
{
    char *stringy = "I am a read only string";
    char str[] = "I am free to change";
    char *str_ptr = str; /* slave of str ;) */

   /* call to fileRead */
    fileRead( stringy );
    fileRead( str );
    fileRead( str_ptr );
    :
    :
    :
    return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.