I want to process data given in a txt file. It has several rows and 2 columns. For my algorithm, I have to use a structure array so that each array item corresponds to one line in the txt file. Within one line, there is a string and a number. Therefore, I created two members of the structure. I go on row-by-row and fill in the structure. However, somehow, I have to reset the structure array pointer to the first element, and this is what I can't achieve.
#include <stdio.h>
void loadData(struct item *inputItems, FILE *inputStream);
void printItemStructure(struct item *itemArray, int nItems);
struct item{
    char *tag;
    double itemSize;
};
int main()
{
    /* Handle the input file */
    char *inputFileName = "d:\\Users\\User\\Downloads\\input.txt";
    FILE *input;
    input = fopen(inputFileName, "r");
    if (input == NULL){
        printf("Could not open the file for reading.");
        return -1;
    }
/* ========== Read the file content to the input structure ========== */
    /*Determine the number of items by counting the rows of the input file */
    int N = 0; /* number of items */
    int nChars = -1; /* number of characters (exclude EOF character) */
    char penChar; /* penultimate character */
    char currentChar = ' '; /* last character read from the file stream */
    char lastChar; /* number of characters */
    while (!feof(input)){
        lastChar = currentChar;
        currentChar = fgetc(input);
        nChars++;
        if (currentChar == '\n')
            N++;
    }
    if (lastChar != '\n' /* the file does not end with '\n' ... */
        && nChars != 0)  /* ... and is not empty */
        N++;
    /* Process data row-by-row */
    struct item *inputItems = calloc(N, sizeof(struct item));
    struct item *origItems = inputItems; /* this will be reseted */
    loadData(inputItems, input);
    inputItems = origItems;
    printItemStructure(inputItems, N);
    /* Close the file */
    fclose(input);
    return 0;
}
void loadData(struct item *inputItems, FILE *inputStream){
    rewind(inputStream);
    char *start = inputItems[0].tag;
    char row[200];
    int rowSize = 200;
    int i = 0;
    char title[200];
    double size;
    while (fgets(row, rowSize, inputStream)){
        sscanf(row, "%s %lf", title, &size); // why doesn't it work directly?
        inputItems[i].tag = title;
        inputItems[i].itemSize = size;
        printf("%s\n", row);
        i++;
    }
}
void printItemStructure(struct item *itemArray, int nItems){
    /* Print the members of the item structure array for debugging purposes */
    for (int j = 0; j<nItems; j++)
    {
        printf("\nitemArray[%d]\n   Tag: %s,   Size: %lf\n",
            j, itemArray[j].tag, itemArray[j].itemSize);
    }
}
Why can't I reset the *tag field of the inputItems structure array?
The input.txt file contains:
Film1 1.8
Film2   4.25
 
    