Создать аналог prinf для вывода значений типа int, double, float, long, char

Не могу понять, почему не выводит значения когда я вызываю функцию. Помогите


#include <iostream>
#include <stdarg.h>
#include <string.h>
#include <conio.h>
using namespace std;

void print(int count, char types[], ...);

int main(void)
{
    
}

void print(int count, char types[], ...)
{
    va_list v;
    va_start(v, types);
    for (int i = 0; i < count; i++)
    {
        if (types[i] == 'd')
        {
            int a = va_arg(v, int);
            cout << "%d " << a;
        }
        else if (types[i] == 'lf')
        {
            double b = va_arg(v, double);
            cout << "%lf " << b;
        }
        else if (types[i] == 'f')
        {
            float c = va_arg(v, float);
            cout << "%f " << c;
        }
        else if (types[i] == '%ld')
        {
            long d = va_arg(v, long);
            cout << "%ld " << d;
        }
        else if (types[i] == '%s')
        {
            char* s = va_arg(v, char*);
            cout << "%s " << s;
        }
    }
    for (int i = 0; i < count; i++)
    {
        cout << types[i] << "\t";
    }
}


Ответы (0 шт):