I'm a complete noob and I need help! I like everything written correctly, here's the code:
Code:
#include <stdio.h>
#include "iwlib.h"

int set_essid(int    skfd, char ifname[], char arg[], int count);

int main(int argc, char *argv[])
{
  int skfd;
  if((skfd = iw_sockets_open()) < 0)
  {
    perror("socket");
    exit(-1);
  }
  
  if(argc != 3) {
    printf("USING: %s [FACE] [essid]\n", argv[0]);
    goto quit;
  }
  
  if( set_essid(skfd, argv[2], argv[3], 0) == 0 ) {
    printf("OK!\n");
  }
  else {
    printf("ERROR!\n");
    perror("iw_set_ext");
  }
  
  quit:
  iw_sockets_close(skfd);
  return 0;
}

int set_essid(int    skfd, char ifname[], char arg[], int count)
{
  struct iwreq wrq;
  char essid[IW_ESSID_MAX_SIZE + 1];
  int we_kernel_version;
  
  
  wrq.u.essid.flags = 1;
  strcpy(essid, arg);
  
  we_kernel_version = iw_get_kernel_we_version();
  
  wrq.u.essid.pointer = (caddr_t) essid;
  wrq.u.essid.length = strlen(essid);
  if(we_kernel_version < 21)
    wrq.u.essid.length++;

  if(iw_set_ext(skfd, ifname, SIOCSIWESSID, &wrq) < 0)
    return(-1);
  
  return 0;
}
I compiled this way
Code:
gcc libiw.so.29 main.c -lm -Wall
At startup gives an error:
Code:
user $ ./a.out wifi d
Segmentation error (the memory stack is flushed to disk)
Help me!!!!