Skip to content

Instantly share code, notes, and snippets.

View frankie-yanfeng's full-sized avatar
🎬
"What I cannot create, I do not understand" - Richard Feynman

Yan Feng frankie-yanfeng

🎬
"What I cannot create, I do not understand" - Richard Feynman
View GitHub Profile
@frankie-yanfeng
frankie-yanfeng / main.c
Last active January 8, 2020 08:05
Two Layer Pointers
/* main.c */
#include <stdio.h>
#include "redirect_ptr.h"
int main(void)
{
const char *firstday = NULL;
const char *secondday = NULL;
get_a_day(&firstday);
get_a_day(&secondday);
@frankie-yanfeng
frankie-yanfeng / main.c
Created January 9, 2020 03:37
C Callback function
/* main.c */
#include <stdio.h>
#include "para_callback.h"
void say_hello(void *str)
{
printf("Hello %s\n", (const char *)str);
}
void count_numbers(void *num)
#include <stdio.h>
void func (void *pv)
{
char *pchar = pv;
*pchar = 'A';
}
int main()
{
@frankie-yanfeng
frankie-yanfeng / flexibleArray.c
Created January 9, 2020 12:51
Flexible array member
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUFFLEN 10
typedef struct example *PtrToExample;
struct example{
int a;
int p[0];
};
@frankie-yanfeng
frankie-yanfeng / generics.c
Created January 10, 2020 01:56
generic example
/* generics.c */
#include "generics.h"
void *max(void *data[], int num, cmp_t cmp)
{
int i;
void *temp = data[0];
for(i=1; i<num; i++) {
if(cmp(temp, data[i])<0)
temp = data[i];
}
@frankie-yanfeng
frankie-yanfeng / myprintf.c
Created January 10, 2020 02:52
Variadic function
#include <stdio.h>
#include <stdarg.h>
void myprintf(const char *format, ...)
{
va_list ap;
char c;
va_start(ap, format);
while ( (c = *format) ) {
format++;
@frankie-yanfeng
frankie-yanfeng / Sentinel.c
Created January 10, 2020 03:36
Sentinel Example
#include <stdio.h>
#include <stdarg.h>
void printlist(int begin, ...)
{
va_list ap;
char *p;
va_start(ap, begin);
p = va_arg(ap, char *);
@frankie-yanfeng
frankie-yanfeng / linkedList.c
Last active January 10, 2020 05:56
Single List
/* linkedlist.c */
#include <stdlib.h>
#include "linkedlist.h"
//static link head = NULL;
static List ListHead;
link make_node(unsigned char item)
{
link p = malloc(sizeof *p);
@frankie-yanfeng
frankie-yanfeng / doubleList.c
Last active January 10, 2020 06:32
Double List
#include "doubleList.h"
/* linkedlist.c */
#include <stdlib.h>
#include "doubleList.h"
//static link head = NULL;
static List ListHead;
link make_node(unsigned char item)
{
@frankie-yanfeng
frankie-yanfeng / main.dart
Last active July 1, 2020 16:22 — forked from webianks/main.dart
Scanning Animation In Flutter
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:scanning_aimation/scanner.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {