Jump to content

Hello visitors, welcome to the Hacker World Forum!

Red Team 1949  (formerly CHT Attack and Defense Team) In this rapidly changing Internet era, we maintain our original intention and create the best community to jointly exchange network technologies. You can obtain hacker attack and defense skills and knowledge in the forum, or you can join our Telegram communication group to discuss and communicate in real time. All kinds of advertisements are prohibited in the forum. Please register as a registered user to check our usage and privacy policy. Thank you for your cooperation.

TheHackerWorld Official

C语言正则表达式匹配

Featured Replies

Posted

 

C语言中使用正则表达式一般分为三步:

  1. 编译正则表达式 regcomp()
  2. 匹配正则表达式 regexec()
  3. 释放正则表达式 regfree()

下边是对三个函数的详细解释:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <
#include <netdb.h>

#define SERVER_PORT    80
#define SERVER_DOMAIN_NAME    "api.help.bj.cn"

void sys_err(const char *str)
{
    perror(str);
    exit(1);
}

int main(int argc, char *argv[])
{
    struct hostent *host_info;

    host_info = gethostbyname(SERVER_DOMAIN_NAME);
    if(host_info == NULL){
        sys_err("hostInfo is NULL\r\n");
        return -1;
    }

     printf("host name:%s\r\n", host_info->h_name);
    //  printf("alias list:%s\r\n", host_info->h_aliases);
    // printf("type:%d\r\n", host_info->h_addrtype);
    // printf("length:%d\r\n", host_info->h_length);
    // printf("address list:%s\r\n",host_info->h_addr_list);

    // close(sfd);
    
    return 0;
}

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.