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. Otherwise, if your r["content"] happens to return a string that contains "%s" or some other thing that causes fprintf to look for more data on the stack, you'll get output you weren't expecting. --Pete On Thu, Aug 02, 2007 at 11:04:13AM +0800, wangxu wrote: > 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; > char *fname=new char[50]; > fname[0]='\0'; > strcat(fname,HTML_HOME.c_str()); > strcat(fname,id); > strcat(fname,".html"); > fp1 = fopen(fname, "w"); > fprintf (fp1, r["content"]); > fclose(fp1); > delete fname; > } > > Warren Young wrote: > >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 300000, > > > >How certain are you about this threshold? It seems a very odd number > >for a computer to care about. If you'd said 65536 bytes, or 16.7 MB, > >I'd put a lot more credence in your assertion. > > > >> mysqlpp::Row r; > >> while (r = res.fetch_row()) { > >> printf (r["content"]); > >> } > > > >I'm not sure it's the problem, but you really shouldn't use printf() > >for this. The main reason is that printf() will scan the resulting > >string for % signs and try to interpret them as formatting options. > >If it finds any, it will then try to find varargs, and fail; this > >would easily explain your segfault. The byte count does affect the > >chances that this will happen, so maybe that's where your perception > >that it's data size related comes from. > > > >Other reasons not to use printf() with MySQL++ data types are > >inefficiency and type safety. > > > >See examples/cgi_jpeg.cpp for the right way to emit bulk MySQL++ to > >stdout. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]