I have a file that looks like this:
Kathryn 1561 2589.98
Hollie 2147 2496.36
Sherlock 3574 2514.65
and my fscanf - related code is as follows:
int load_data(char* fileName, char** accountNames, int* accountNumbers, float* amounts, int numOfAccounts)
{
    FILE *fPtr = fopen(fileName, "r");
    int counter = 1, test;
    if(fPtr  == NULL)
    {
            fclose(fPtr);
            return 0;
    }
    else
    {
            test = fscanf(fPtr,"%20s%d%f",  *accountNames, accountNumbers, amounts);
            printf("%d\n", test);
            while(counter < numOfAccounts)
            {
                test = fscanf(fPtr,"%20s%d%f",  *accountNames, accountNumbers, amounts);
                    printf("%d\n", test);
                    counter++;
            }
            fclose(fPtr);
            return 1;
    }
}
Here is the calling code:
int main(int argc, char** argv)
{
        int numOfAccounts = atoi(*(argv + 2));
        char* fileName = *(argv + 1);
        char** accountNames = malloc(sizeof(char) * 20 * numOfAccounts);
        int* accountNums = malloc(sizeof(int) * numOfAccounts);
        float* amounts = malloc(sizeof(float) * numOfAccounts);
        int dataload = load_data(fileName, accountNames, accountNums, amounts, numOfAccounts);
        dataload++;
return 0;
}
The if statement works, and the file is recognized. However, fscanf only returns 0. I'm really really new at C and fscanf so I ask that you be patient as I am learning, but if anyone could help me that would be great. Please let me know if I need to include more information. Thank you.
 
     
     
     
    