Reputation: 5
What does it mean by these error?
I was trying to build a simple _printf function but while trying to pass this va_list I am getting some expression errors.
main.c: In function ‘_printf’:
main.c:101:28: error: expected expression before ‘va_list’ count = _mySwit(c, va_list args, count);
main.c:101:17: error: too few arguments to function ‘_mySwit’ count = _mySwit(c, va_list args, count);
main.c:60:5: note: declared here int _mySwit(char letter, va_list pargs, int cou)
##########################################################################
{
char leter, *str;
int i = 0;
switch (letter)
{
case 'c':
leter = (char) va_arg(pargs, int);
_putchar(leter);
cou++;
break;
case 's':
str = va_arg(pargs, char *);
while(str[i] != '\0')
{
_putchar(str[i]);
cou++; }
i = 0;
break;
default:
break;
}
return (cou);
}
char _printf(char *format, ...)
{
va_list args;
char *string, *inStr;
int inarg, count;
va_start(args, format);
if (*format == '%')
{
char c = *format++;
count = _mySwit(c, va_list args, count);
*format++; }
else
_putchar(*format);
count++;
return (count);
}```
##################################################################
Upvotes: 0
Views: 416
Reputation: 5
When passing the va_list, typing it count = _mySwit(c, args, count);
that way works instead of. count = _mySwit(c, va_list args, count);
Upvotes: 0