0
#include <stdio.h>

int print_cool_characters(char *printable_message) {
    printf("\033[36m Cyan text: %s \033[39m \n", printable_message);
}

int main(void) {
    print_cool_characters("This is very cool! Also, here's a number: %i.", 123);
}

Invoke GCC... error: too many arguments to function.

1 Answers1

0

You must use varargs:
Here is a little example: https://www.eskimo.com/~scs/cclass/int/sx11b.html
And a related question: An example of use of varargs in C
And you are probably trying to write a printf-like function: How to write custom printf?, http://www.firmcodes.com/write-printf-function-c/
I wrote the function over again with the %i detector

#include <stdio.h>
#include <stdarg.h>

void print_cool_characters(char *c, ...) {
    printf("\033[36mCyan text: ");
    char *s;
    va_list lst;
    va_start(lst, c);
    while(*c != '\0') {
        if(*c != '%') {
            putchar(*c);
            c++;
            continue;
        }
        c++;
        switch(*c) {
            case 'i': printf("%d", va_arg(lst, int)); break;
        }
        c++;
    }
    printf("\033[39m\n");
}

int main(void) {
    print_cool_characters("This is very cool! Also, here's a number: %i.", 123);
}
PQCraft
  • 328
  • 1
  • 8