E
Eric Lilja
Hello, I have two code snippets I want you to look at. My program compiles
without warnings (warning level set to max, gcc 3.4.3) with either snippet
but the latter one causes a segfault at run-time. I know it contains
non-standard constructs (using the MySql C api) but I wanted to know if it's
printf() I'm misuing. Here are the snippets:
/* m is of type MYSQL* */
unsigned int code = mysql_errno(m);
const char *description = mysql_error(m);
if(code && description)
{
printf("Failed to create chemistry recipe table.\n"
"Error code: %d\n"
"Description: %s\n", code, description);
}
This snippet doesn't segfault at runtime but the following one does:
printf("Failed to create chemistry recipe table.\n"
"Error code: %d\n"
"Description: %s\n", mysql_errno(m), mysql_error(m));
Both snippets produce the same output though. Is this mis-use of printf() in
the last snippet or a mysql c api problem (if so, I will ask this question
elsewhere)?
Thanks for any help
/ Eric
without warnings (warning level set to max, gcc 3.4.3) with either snippet
but the latter one causes a segfault at run-time. I know it contains
non-standard constructs (using the MySql C api) but I wanted to know if it's
printf() I'm misuing. Here are the snippets:
/* m is of type MYSQL* */
unsigned int code = mysql_errno(m);
const char *description = mysql_error(m);
if(code && description)
{
printf("Failed to create chemistry recipe table.\n"
"Error code: %d\n"
"Description: %s\n", code, description);
}
This snippet doesn't segfault at runtime but the following one does:
printf("Failed to create chemistry recipe table.\n"
"Error code: %d\n"
"Description: %s\n", mysql_errno(m), mysql_error(m));
Both snippets produce the same output though. Is this mis-use of printf() in
the last snippet or a mysql c api problem (if so, I will ask this question
elsewhere)?
Thanks for any help
/ Eric