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?

Recommended Answers

All 7 Replies

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"?

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

commented: ...forget it, I'm not gonna go near that one. +4

forget it, I'm not gonna go near that one

um, yeah, i need to proof my posts a bit more carefully...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.