c语言版本的coroutine
#include <stdio.h> int function(void) { static int i, state = 0; switch (state) { case 0: goto LABEL0; case 1: goto LABEL1; } LABEL0: /* start of function */ for (i = 0; i < 10; i++) { state = 1; /* so we will come back to LABEL1 */ return i; LABEL1:; /* resume control straight after the return */ } } int main(){ printf(":%d\n" , function()); printf(":%d\n" , function()); printf(":%d\n" , function()); printf(":%d\n" , function()); printf(":%d\n" , function()); return 0; }
想过,但是没想到,还真有啊!
MySQL限时解答,24小时内友哥专业解答
http://www.yougemysqldba.com
如有进一步需要请联系微信onesoft007
微博账号@友哥一指
http://www.yougemysqldba.com
如有进一步需要请联系微信onesoft007
微博账号@友哥一指