Skip to content

DC-Jade/c_notebook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

c_notebook

Introduction

Supported

  • os
    • Ubuntu 16.04 LTS
  • compiler
    • gcc version 9.4.0

char

  • char is a short integer, only 1B(8 bit)

  • type conversion(or typecasting)

    int a = '1' - '0'	/* char int to digit */
    printf("%d\n", a);
  • char array, refers array storing chars

    char ca[];

pointer*

  • void * can be casted to any pointer without losing information

  • pointer is a variable, hexademical int, different to array name

    int ia[4] = {0, 1, 2, 3};
    int *pa = ia;
    pa++	/* right */
    ia++	/* wrong, only variable can*/

Struct

  • Store many different type variables

    struct Pointer {
        int x = 0;
        int y = 0;
    };	/* struct Pointer */
    struct Pointer p;	/* instantiation */

function()

  • function returning a pointer

    Void *fun(int);
  • pointer to a function

    void (*pfun) (int);
  • function parameter

    void fun(char s[]);
    void fun(char *s);	/* char s[] same as char *s and char *s mostly used */

array[]

  • pointer array, refers to array storing pointers

    int *ia[100];
    char *ca[100] = {"string", "hello", "world"};	/* mostly used to save string */
    printf("%s %s %s\n", ca[0], ca[1], ca[2], ca[3]);
  • pointer to an array

    int (*pa)[100];
  • array name, refers to a pointer to the first element of array

    int ia[10]; 
    printf("%p %p", ia, &ia[0])  /* ia same as &ia[0]; */
  • index, refers to dereference address

    /* ia[i] same as *(ia + i) */

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published