This may be a bit off topic, but if you are making the up-front design
decision to use the C++ API instead of the more entrenched C API, why
would you use the printf family of functions at all? They are
deprecated in C++ in favour of iosteams which avoid the kind of buffer
overrun issues you are
wangxu wrote:
actually I am using this piece of code,but I replaced fprintf to printf
just to simplify the problem.
Everything I said about printf() applies equally to fprintf(). The %s
work-around suggested by Pete Harlan will work, but not for very good
reasons. Again: see
He's saying that instead of this:
fprintf (fp1, r[content]);
You at least want something like this:
fprintf (fp1, %s, r[content]);
if you're going to use fprintf, or, if you want something more
c++-like, you'd use a function besides fprintf altogether.
below is my code;these code works very fine until, the length of the
field content exceeds 30,
then segment fault happened.
how can I avoid this?
mysqlpp::Query query = conn.query();
query select content from pages where id=id;
mysqlpp::ResUse
I'm replying to you both personally and to the MySQL++ mailing list,
where this message is on topic. Please reply only on the list, not to
me directly.
wangxu wrote:
below is my code;these code works very fine until, the length of the
field content exceeds 30,
How certain are you
actually I am using this piece of code,but I replaced fprintf to printf
just to simplify the problem.
and the field content actually stores string content.
Shall this mean some thing different from your explanation?
while (r = res.fetch_row()) {
FILE *fp1;