0
$\begingroup$
#include <stdio.h>
#include <stdlib.h>

int arguments(char ** filename, int argc , char ** argv )
{
    if(argc < 2)
    {
        return -1;
    }
    else
    {
        filename = argv;
        return 1;
    }

}
int main (int argc, char ** argv )
{
    char ** filename;
    FILE *fp;

    int ret = arguments(&filename, argc , argv);
    if(ret == -1)
    {
        perror("Error, something occured.\n");
    }
    printf("The file is called %s\n",filename);
    return 0;
}

I want to send in an empty array to the function arguments(), and if it satisfies then I want
to actually change (override) the array with the name they put in. I have done this in C++
but it is weird on C...
New contributor
Jorge Avila is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$
  • $\begingroup$ This is not the right stack Exchange site for this, but as a guess, I notice that you are taking a reference to filename before passing it to arguments when it is already a char ** $\endgroup$ – Ryan1729 2 days ago
  • $\begingroup$ @ryan1729 Oh ok, thank you.... $\endgroup$ – Jorge Avila yesterday

Browse other questions tagged or ask your own question.