I'm writing essentially an implementation of printf. I want it so you can pass many strings within strings, e.g.:
kprintf("Hello %s", "Goodbye %s", "Farewell\n");
Don't ask why, it may very well be insane. Anyway, it recursively calls itself after looking for how many % characters are in the string it is passing; so if more than one % is in it, it should pass many arguments. However, I've been unable to achieve this with any elegance, see the below one:
case 1:
kprintf(str, argus[0]);
break;
case 2:
kprintf(str, argus[0], argus[1]);
break;
case 3:
kprintf(str, argus[0], argus[1], argus[2]);
break;
case 4:
kprintf(str, argus[0], argus[1], argus[2], argus[3]);
break;
case 5:
kprintf(str, argus[0], argus[1], argus[2], argus[3], argus[4]);
break;
With argus as an array of pointers. This works, but I hate it. Is there a way to pass variable arguments to a function ?
kprintf("%d %s", 47, "%u", 11);, should that work like Python's"%d %s" % (47, "%u" % 11)and print47 11? If so, good luck! :)va_argpointer (likevprintfdoes)?