zoukankan      html  css  js  c++  java
  • glib helloworld

    glib简单使用:

    #include <errno.h>
    #include
    <math.h>
    #include
    <stdio.h>
    #include
    <stdlib.h>
    #include
    <string.h>
    #include
    <glib.h>
    /*
    * === FUNCTION ======================================================================
    * Name: main
    * Description: main function
    * =====================================================================================
    */
    int
    main (
    int argc, char *argv[] )
    {
    GString
    * p_gstr = g_string_new(NULL);
    char* desStr = (char*)malloc(10);
    memset(desStr,
    '1', 9);
    desStr[
    9] = '\0';
    g_string_sprintfa(p_gstr,
    "\"post_summary\":\"%s\",", desStr);
    free(desStr);
    char* buf = (char*)malloc(p_gstr->len + 1);
    strncpy(buf, p_gstr
    ->str, p_gstr->len);
    g_string_free(p_gstr, TRUE);
    buf[p_gstr->len] = '\0';
    printf (
    "\nProgram %s\n\n", buf );
    free(buf);
    return EXIT_SUCCESS;
    }
    /* ---------- end of function main ---------- */

    编译:

    gcc -g -Wall -O0 a.c -o a `pkg-config --libs --cflags glib-2.0`
  • 相关阅读:
    CentOS
    Docker
    Chart的简单使用
    DataGridView中间插入数据行
    获取每个月的固定的第n个星期几
    设置只能开启一个程序实例
    DataContext与实体类
    Attribute
    Delegate
    Event
  • 原文地址:https://www.cnblogs.com/wangkangluo1/p/2082309.html
Copyright © 2011-2022 走看看