I'm having trouble making a variable argument function for my class. When I gcc it, its giving me these errors:

my_printf.c: In function `print_str':
my_printf.c:14: error: syntax error before '{' token
my_printf.c:20: error: syntax error before "__builtin_stdarg_start"

here's a code snippet:

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

// ASCII definitions
#define NEWLINE 10
#define BACKSLASH 92
#define QUOTE 39
#define QUOTES 34
#define QUESTION 63


int my_printf(char *string_ptr, ...)
{
    va_list ap; 
    int integer; 
    char character; 
    char *char_string; 
    
    va_start(ap, string_ptr);
    
}

does anyone know whats wrong?

my_printf.c: In function `print_str':

I suspect you're not posting all of the relevant code. print_str isn't mentioned except in the error.

Problem is not with the code you posted here. I suspect it is a syntax error that occurs before the myprintf() function. Do check your code before that, specifically the print_str() function.

thanks for helping. I don't want to post more code because I fear that I would be breaking the academic honesty code of this class. I did get it to work, however. It was a syntax error in my header file. thanks again.

I don't want to post more code because I fear that I would be breaking the academic honesty code of this class.

any time you solicit code help from any source, you are technically in danger of violating academic integrity. In this case, since no one gave you any code, probably not. But you should cite all online help sources that you use, just to be on the safe side. The general rule is: If you cite it, you can never be accused of dishonesty.

oh, and hey, "Coke Asian Psycho": are you related to the "Coke Dude"?

Edited 6 Years Ago by jephthah: n/a

no, It's actually supposed to be caucasian psycho, but nobody gets it. You were one of the closest

aha. well, internet memes force us all to read "azn" these days.

tho i admit, the "cok" didn't quite fit. It's only because i'm infatuated with a user named "Coke Dude". I'm his secret stalker :P

Edited 6 Years Ago by jephthah: n/a

Comments
...forget it, I'm not gonna go near that one.
This article has been dead for over six months. Start a new discussion instead.