Function equivalent to sprintf() with maximum number of characters to be copied?

Posted by Tommy on Stack Overflow See other posts from Stack Overflow or by Tommy
Published on 2010-04-23T23:59:45Z Indexed on 2010/04/24 0:03 UTC
Read the original article Hit count: 126

Filed under:
|
function(char* name)
{       
   char sql[50];
   sprintf(sql, "select %s;", name);
}

What's the best way to make sure only 50 chars of name are copied to sql in the case name is larger than what sql can hold? (sprintf with a N parameter?)

Thank You.

© Stack Overflow or respective owner

Related posts about c

    Related posts about c++