title: why am I getting segmentation fault on the code below?
body: <p>I have a txt file where I just want to get lines bigger than 12 characters. Than these lines are inserted in a variable called graph of type graph_node.</p>
  
  <p>txt file:</p>
  
  <pre><code>1,"execCode(workStation,root)","OR",0
  2,"RULE 4 (Trojan horse installation)","AND",0
  3,"accessFile(workStation,write,'/usr/local/share')","OR",0
  4,"RULE 16 (NFS semantics)","AND",0
  5,"accessFile(fileServer,write,'/export')","OR",0
  6,"RULE 10 (execCode implies file access)","AND",0
  7,"canAccessFile(fileServer,root,write,'/export')","LEAF",1
  6,7,-1
  </code></pre>
  
  <p>graph node type:</p>
  
  <pre><code>#ifndef Graph_Structure
  #define Graph_Structure
  
  struct Graph_Node{
  
      char id[50];
      char node_name[50];
  
      struct Graph_Node* next;
      struct Graph_Node* edges;
  
      };  
  
  typedef struct Graph_Node graph_node;
  
  
  #endif   
  </code></pre>
  
  <p>this is the method to insert data into graph variable:</p>
  
  <pre><code>void insert_node(graph_node** node, graph_node* data){
  
      printf("\nINSERTING\n");
  
      graph_node* temp = (graph_node*)malloc(sizeof(graph_node));
  
      for(int i = 0; i &lt; strlen(data-&gt;id); i++)
          temp-&gt;id[i] = data-&gt;id[i];
  
      for(int i = 0; i &lt; strlen(data-&gt;node_name) - 1; i++)
          temp-&gt;node_name[i] = data-&gt;node_name[i];
  
      temp -&gt; next = *node;
      *node = temp;
  
      }
  </code></pre>
  
  <p>this is the method to get the lines in the txt file bigger than 12 characters:</p>
  
  <pre><code>void generate_nodes(graph_node** graph, char* file_name){
  
      graph_node* data = (graph_node*)malloc(sizeof(graph_node));
  
      FILE* f_Data_Pointer = fopen(file_name, "r");
      FILE* f_Aux_Pointer = fopen(file_name, "r");
  
      char c = 0; char line[256];
  
          int counter = 0; 
          int q = 0; //quotation marks
  
          bool jump_line = false;
  
      while(!feof(f_Data_Pointer)){
  
          c = 0; memset(line, 0, sizeof(line));
  
          while(c != '\n' &amp;&amp; !feof(f_Aux_Pointer)){ // check line
  
              c = fgetc(f_Aux_Pointer); 
              line[counter] = c;
              counter++;
  
          }
  
          if(strlen(line) &gt; 12){ //lines with no edges  
  
           /*line[counter-3] != '-' &amp;&amp; line[counter-2] != '1'*/
  
           int size = strlen(line); printf("\nline size: %d\n", size);
  
              counter = 0; c = 0;
  
              while(c != ','){ //id
  
                  c = fgetc(f_Data_Pointer);
  
                  if(c != ','){
  
                      data-&gt;id[counter] = c;          
                      counter++;
                  }
  
                  printf("%c", c);
  
              }
  
  
              counter = 0; c = 0;
  
              while(1){ //node_name
  
                  c = fgetc(f_Data_Pointer);
  
                  if(c != '"'){
  
                  data-&gt;node_name[counter] = c;
                  counter++;
  
                  } 
  
                  else{
  
                      q++;                
                  }
  
                  if(q &gt; 1 &amp;&amp; c == ',')
                      break;
  
                  printf("%c", c);
  
              }
  
              counter = 0; c = 0; 
  
              while(c != '\n'){ 
  
                  c = fgetc(f_Data_Pointer);
                  printf("%c", c);
  
              }
  
              insert_node(graph, data);
              memset(data-&gt;id, 0, sizeof(data-&gt;id));
              memset(data-&gt;node_name, 0, sizeof(data-&gt;node_name));
  
          }
  
          else{ //lines with edges
  
              while(c != '\n' &amp;&amp; !feof(f_Data_Pointer)){ 
  
                  c = fgetc(f_Data_Pointer);
  
              }
  
          }
  
      }
  
      fclose(f_Data_Pointer);
      fclose(f_Aux_Pointer);
  
  }
  </code></pre>
  
  <p>I am getting the errors inside the insert method on the commands "for" in "strlen" it says that data->id and data->node_name are not initialized but I don't understand why. I used malloc on data: </p>
  
  <pre><code>graph_node* data = (graph_node*)malloc(sizeof(graph_node));
  </code></pre>
  
  <p>error:</p>
  
  <pre><code>Conditional jump or move depends on uninitialised value(s) ==3612== at 0x4C30B18: strcpy (vg_replace_strmem.c:510) ==3612== by 0x4008B2: insert_node (mulval.c:44) ==3612== by 0x400C03: generate_nodes (mulval.c:159) ==3612== by 0x400CE8: main (mulval.c:187)
  </code></pre>