title: Linux C programing
body: <p>Its the 1st time im making a question here , so i hope im not making any mistakes...
  Im doing a server-client program and i have this error when i run client, i have "core dumped error".</p>
  
  <p>I think i know where is the error but i dont know how to solve it.
  I have 2 structs : </p>
  
  <pre><code>typedef struct {
      int pid;
      int cmd; //1 -login,2-registrar,3-tecla
      char login[100];
      char pw[100];
      int tecla;
  } PEDIDO;
  
  typedef struct {
      int cmd;
      int res;
      BONECO *b;
  } RESPOSTA;
  </code></pre>
  
  <p>Code when server sends data to client through a named pipe : </p>
  
  <pre><code>int main(int argc, char *argv[], char *envp[]){
  //...
       i = read(fd, &amp;p, sizeof (p));
                      printf("&gt;&gt;&gt; Li %d bytes\n", i);
                      printf("User : %s PID : %d\n", p.login, p.pid);
                      if (p.cmd == 1) { //LOGIN
  
                          char user_fd[100], pw_fd[100];
                          FILE *f = fopen(argv[1], "r");
                          if (!f) {
                              printf("Erro ao abrir ficheiro\n");
                              exit(0);
                          }
                          while ((fscanf(f, "%s %s ", user_fd, pw_fd))) {
                              if (strcmp(p.login, user_fd) == 0 &amp;&amp; strcmp(p.pw,pw_fd) == 0) {
                                  printf("\nLOGIN CORRECTO!!!\n");
                                  for (i = 0; i &lt; 20; i++) {
                                      if (clientes[i][0] != p.pid &amp;&amp; clientes[i][0] == -1) {
                                          clientes[i][0] = p.pid;
                                          break;
                                      }
                                  }
                                  sprintf(cli_fifo, "ccc%d", p.pid);
                                  fd_resp = open(cli_fifo, O_WRONLY);
                                  r.cmd = 1;
                                  r.res = 1;
                                  i = write(fd_resp, &amp;r, sizeof (r));
                                  close(fd_resp);
                                  fclose(f);
                                  break;
                              }
  
  //...
  
  }
  </code></pre>
  
  <p>Code of client to receive data from server : </p>
  
  <pre><code>void *recebe_msg(void *dados) {
      int i;
      sprintf(cli_fifo, "ccc%d", getpid());
      mkfifo(cli_fifo, 0600);
      fd_resp = open(cli_fifo, O_RDWR);
      menu();
      do {
          i = read(fd_resp, &amp;r, sizeof (r));
          if (ESTADO == 0) {
              if (r.cmd == 1 &amp;&amp; r.res == 1) { // OK
                  ESTADO = 1;
                  wclear(win);
                  mvwprintw(win, 10, 14, "Login efectuado com sucesso!");
  
                  wprintw(win, "BONECO %d, %d , %d , %d ",r.b[0].num,r.b[0].humano,r.b[0].remate,r.b[0].tempo);
  
                  wrefresh(win);
                  sleep(3);
                  desenha_campo();
              }
              if (r.cmd == 1 &amp;&amp; r.res == 0) { // NOK
                  wclear(win);
                  mvwprintw(win, 10, 14, "Senha e/ou login incorrectos!!!");
                  wrefresh(win);
                  sleep(3);
                  menu();
              }
              if (r.cmd == 2 &amp;&amp; r.res == 0) {
                  wclear(win);
                  mvwprintw(win, 10, 14, "Login já está em uso!");
                  wrefresh(win);
                  sleep(3);
                  menu();
              }
              if (r.cmd == 2 &amp;&amp; r.res == 1) {
                  wclear(win);
                  mvwprintw(win, 10, 14, "Registo efectuado com sucesso!");
                  wrefresh(win);
                  sleep(3);
                  menu();
              }
  
              if (r.cmd == 9) { // sair
                  FIM = 1;
              }
          } else if (ESTADO == 1 || ESTADO == 2) {
              wclear(win3);
              scrollok(win3, TRUE);
              keypad(win3, TRUE);
              noecho();
              if (r.cmd == 3) { // actualizacao de jogadores
                  desenha_campo();
                  desenha_jogadores();
              } else if (r.cmd == 9) { // sair
                  FIM = 1;
              }
          }
      } while (!FIM);
  
      close(fd_resp);
      unlink(cli_fifo);
      pthread_exit(0);
  }
  </code></pre>
  
  <p>OBS: I think the error is on the 3rd field of struct RESPOSTA, but i dont know how to solve it </p>