C language: Simulate printf. required function: print ("ccc \ ts! ", 'B', 'I', 't'," welcome to you ");
Program:
# Include <stdio. h> # include <stdlib. h> # include <stdarg. h> int my_printf (const char * fmt ,...) {const char * s; char c; va_list ap; // parameter list va_start (ap, fmt); // get the fmt pointer to apwhile (* fmt) {/* if (* fmt! ='S '| * fmt! = 'C') {putchar (* fmt ++); continue;} */switch (* fmt) {case's ': s = va_arg (ap, const char *); // get the parameter for (; * s; s ++) // print the string content {putchar (* s) through a loop;} break; case 'C': c = va_arg (ap, char); putchar (c); break; default: putchar (* fmt); break;} fmt ++ ;} va_end (ap); // set 0} int main () {char a = 'B'; my_printf ("ccc \ ts! ", 'B', 'I', 't'," welcome to you "); system (" pause "); return 0 ;}
Result: bit welcome to you! Press any key to continue...