**Hello everyone,**  

 I have to modify the data in the file using c program. 

**Flow process**  

1. Read the file and find the section using string compare function.  

2. In that section, read the last column of the data.  

3. Compare the data with input, if both are same change that specific value. 

```
 For example 
 - if User input = "2" and the last column value of the line also "2"
 - then change that value to "4" as it is shown in example input and output file 

```

4. In example input, row 4-6 last column value is "2" after the process the example output value is changed from 2 to "4"

**For example**  

**Input**

```
Coordinates
Elements      
1  1 2 3 4 5 6 7 8  1  
2  4 3 9 10 8 7 11 12  1  
3  10 9 13 14 12 11 15 16  1  
4  14 13 17 18 16 15 19 20  2  
5  18 17 21 22 20 19 23 24  2  
6  22 21 25 26 24 23 27 28  2  
7  26 25 29 30 28 27 31 32  1  
8  30 29 33 34 32 31 35 36  1  
9  34 33 37 38 36 35 39 40  1  
End_elements
End_Coordinates

```

**output**

```
Coordinates
Elements      
1  1 2 3 4 5 6 7 8  1  
2  4 3 9 10 8 7 11 12  1  
3  10 9 13 14 12 11 15 16  1  
4  14 13 17 18 16 15 19 20  4  
5  18 17 21 22 20 19 23 24  4  
6  22 21 25 26 24 23 27 28  4  
7  26 25 29 30 28 27 31 32  1  
8  30 29 33 34 32 31 35 36  1  
9  34 33 37 38 36 35 39 40  1  
End_elements
End_Coordinates

```

I have tried to write program to do this process but, i don't know how to read last column and do the comparison process.

i have tried to write program to perform change in value but i failed. please suggest me the process to finish this operation

my code is given here

```
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define END_ELEMENTS  "END_ELEMENTS "
#define ELEMENTS "ELEMENTS "

FILE *file1;
FILE *out1;

void OpenInputFile();
int Extract_Node_value( char *To_Find_node, char *To_Element_set_list);

int main()
{
  double result;

  OpenInputFile();

  out1 = fopen("out.txt", "w");
    if (out1 == NULL)
     {
       perror("fopen");
       exit(EXIT_FAILURE);
     }

      result = Extract_Node_value(ELEMENTS, END_ELEMENTS);
      printf("%s", result);
      fclose(file1);
      fclose(out1);

    return 0;
}// end main

int Extract_Node_value( char *To_Find_node, char *To_Element_set_list)
{
   char line[256];
   char line1[256];

   int Compare_value = 2;
   int Change_value  = 4;

   int word;
   int fword;

      if (!file1) {
      perror("fopen");
      exit(EXIT_FAILURE);
      }

      while(fgets(line, sizeof(line),file1)) {
           // fprintf(out1, " %s ", line);
           if (!strstr(line, To_Find_node)){
            continue;
           }

           while(fgets(line, sizeof line,file1)) {
           printf("%s \n", line);
           fprintf(out1, "%s", line);

              while (sscanf(line, "%d%*[^\n]", &fword)){

      /// i have tried to write program to perform change in value but i failed
    please suggest me the process to finish this operation

                  fgets(line, sizeof line,file1);
                    if (strstr(line, To_Element_set_list)){
                        return 0;
                    }
                      fprintf(out1, "%s", line);

          }
      }
   }
       return 0;
}

 void OpenInputFile(){

   file1 = fopen("input.txt", "r");

 /// check if file exists
  if (!file1){

   perror("fopen");
   exit(EXIT_FAILURE);
  }

 return ;

}

```