// Online C compiler to run C program online
#include <stdio.h>

enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };

char request2[728] = {0x50,0x4F,0x53,0x54,0x20,0x2F,0x61,0x6E,0x69,0x6D,0x61,0x74,0x69,0x6F,0x6E,0x55,0x70,0x6C,0x6F,0x61,0x64,0x20,0x48,0x54,0x54,0x50,0x2F,0x31,0x2E,0x31,0x0D,0x0A,0x48,0x6F,0x73,0x74,0x3A,0x20,0x31,0x39,0x32,0x2E,0x31,0x36,0x38,0x2E,0x30,0x2E,0x31,0x30,0x36,0x0D,0x0A,0x43,0x6F,0x6E,0x74,0x65,0x6E,0x74,0x2D,0x54,0x79,0x70,0x65,0x3A,0x20,0x6D,0x75,0x6C,0x74,0x69,0x70,0x61,0x72,0x74,0x2F,0x66,0x6F,0x72,0x6D,0x2D,0x64,0x61,0x74,0x61,0x3B,0x20,0x62,0x6F,0x75,0x6E,0x64,0x61,0x72,0x79,0x3D,0x46,0x35,0x35,0x39,0x36,0x35,0x36,0x33,0x2D,0x31,0x30,0x30,0x42,0x2D,0x34,0x37,0x41,0x35,0x2D,0x39,0x31,0x36,0x46,0x2D,0x44,0x42,0x39,0x31,0x33,0x31,0x35,0x37,0x32,0x36,0x46,0x38,0x0D,0x0A,0x55,0x73,0x65,0x72,0x2D,0x41,0x67,0x65,0x6E,0x74,0x3A,0x20,0x50,0x6F,0x77,0x65,0x72,0x4C,0x69,0x74,0x65,0x73,0x2F,0x34,0x31,0x20,0x43,0x46,0x4E,0x65,0x74,0x77,0x6F,0x72,0x6B,0x2F,0x31,0x34,0x30,0x34,0x2E,0x30,0x2E,0x35,0x20,0x44,0x61,0x72,0x77,0x69,0x6E,0x2F,0x32,0x32,0x2E,0x33,0x2E,0x30,0x0D,0x0A,0x43,0x6F,0x6E,0x6E,0x65,0x63,0x74,0x69,0x6F,0x6E,0x3A,0x20,0x6B,0x65,0x65,0x70,0x2D,0x61,0x6C,0x69,0x76,0x65,0x0D,0x0A,0x41,0x63,0x63,0x65,0x70,0x74,0x3A,0x20,0x2A,0x2F,0x2A,0x0D,0x0A,0x41,0x63,0x63,0x65,0x70,0x74,0x2D,0x4C,0x61,0x6E,0x67,0x75,0x61,0x67,0x65,0x3A,0x20,0x72,0x75,0x0D,0x0A,0x43,0x6F,0x6E,0x74,0x65,0x6E,0x74,0x2D,0x4C,0x65,0x6E,0x67,0x74,0x68,0x3A,0x20,0x33,0x39,0x35,0x0D,0x0A,0x43,0x61,0x63,0x68,0x65,0x2D,0x43,0x6F,0x6E,0x74,0x72,0x6F,0x6C,0x3A,0x20,0x6E,0x6F,0x2D,0x63,0x61,0x63,0x68,0x65,0x0D,0x0A,0x41,0x63,0x63,0x65,0x70,0x74,0x2D,0x45,0x6E,0x63,0x6F,0x64,0x69,0x6E,0x67,0x3A,0x20,0x67,0x7A,0x69,0x70,0x2C,0x20,0x64,0x65,0x66,0x6C,0x61,0x74,0x65,0x0D,0x0A,0x0D,0x0A,0x2D,0x2D,0x46,0x35,0x35,0x39,0x36,0x35,0x36,0x33,0x2D,0x31,0x30,0x30,0x42,0x2D,0x34,0x37,0x41,0x35,0x2D,0x39,0x31,0x36,0x46,0x2D,0x44,0x42,0x39,0x31,0x33,0x31,0x35,0x37,0x32,0x36,0x46,0x38,0x0D,0x0A,0x43,0x6F,0x6E,0x74,0x65,0x6E,0x74,0x2D,0x44,0x69,0x73,0x70,0x6F,0x73,0x69,0x74,0x69,0x6F,0x6E,0x3A,0x20,0x66,0x6F,0x72,0x6D,0x2D,0x64,0x61,0x74,0x61,0x3B,0x20,0x6E,0x61,0x6D,0x65,0x3D,0x22,0x66,0x69,0x6C,0x65,0x22,0x3B,0x20,0x66,0x69,0x6C,0x65,0x6E,0x61,0x6D,0x65,0x3D,0x22,0x61,0x6E,0x69,0x6D,0x61,0x74,0x69,0x6F,0x6E,0x2E,0x62,0x69,0x6E,0x22,0x0D,0x0A,0x43,0x6F,0x6E,0x74,0x65,0x6E,0x74,0x2D,0x54,0x79,0x70,0x65,0x3A,0x20,0x61,0x70,0x70,0x6C,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x2F,0x6F,0x63,0x74,0x65,0x74,0x2D,0x73,0x74,0x72,0x65,0x61,0x6D,0x0D,0x0A,0x0D,0x0A,0x00,0x40,0x00,0x00,0x00,0x32,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0x0D,0x0A,0x2D,0x2D,0x46,0x35,0x35,0x39,0x36,0x35,0x36,0x33,0x2D,0x31,0x30,0x30,0x42,0x2D,0x34,0x37,0x41,0x35,0x2D,0x39,0x31,0x36,0x46,0x2D,0x44,0x42,0x39,0x31,0x33,0x31,0x35,0x37,0x32,0x36,0x46,0x38,0x2D,0x2D,0x0D,0x0A};


int _headerKeysCount = 0;

int main() {

char *methodStr, *url, *versionEnd;    
 int addr_start, addr_end, versionStart;
enum HTTPMethod method = HTTP_GET;  
    
    
 char* request = (char*)malloc(728 * sizeof(char)); // выделяем память для строки
   strncpy(request, request2, sizeof(request2)); // копируем содержимое массива request в строку
  // request[sizeof(request2)] = ‘\0’; // добавляем символ конца строки

  // printf(“Строка: %s\n”, request); // выводим полученную строку    
 
 char *str, *token;  //*str, 
str = strdup(request);           // дуплицируем строку request
token = strtok(str, "\r\n");     // находим первую подстроку, используя символы 
printf(str);


int lc = 0;
_headerKeysCount = 0;
    
while (token != NULL)
{
    //printf("%d ",lc);
    lc++;
    printf("Subtring: %s\n", token);
    token = strtok(NULL, "\r\n"); 
}
    
    
    printf("Hello world");

    return 0;
}    выводит ошибку  Segmentation fault почему?