I am programming a simple text editor in C. I have to define inuse_head and free_head as global variables.  I need to change the value of the 2 global variables in a function. Here is the code I wrote so far:
#include <stdio.h>
#include <string.h>
struct node
{
    char statement[40];
    int next;
};
struct node textbuffer[25];
int free_head;
int inuse_head;
void insert(int line, char* stat)
{
    FILE *file;
    file=fopen("deneme.txt","a");
    
    if(file!=NULL)
    {
        
        int i;
        int k;
        
        strcpy(textbuffer[line].statement,stat);
        textbuffer[line].next=line+1;
        fprintf(file,textbuffer[line].statement);
        
        for(i=0;i<=25;i++)
        {
            if(textbuffer[i].statement==NULL)
            {
                free_head=i;
                break;
            }
        
        }
        
        for(k=0;k<=25;k++)
        {
            if(textbuffer[k].statement!=NULL)
            {
                inuse_head=k;
                break;
            }
        
        }
    
    }
    
    else
    {
        printf("File couldn't found.");
    }
    fclose(file);
}
int main()
{
    insert(3,"Hello World");
    printf("free list: %d and inuse list: %d",free_head,inuse_head);
    return 0;   
}
Now when I print free_head and inuse_head, it prints 0 for both of them.  I need to change free_head's and inuse_head's values in function insert.  I think I should handle it with pointers but how?
 
     
    