I found the following code:
char query[255];
sprintf(query, "SELECT NOMBRE, ");
switch (tipo)
{
case TIPO_1:
sprintf(query, "%s ID", query);
break;
case TIPO_2:
sprintf(query, "%s APELLIDO", query);
break;
}
And what worries me is the use of query
making the role of both read and write parameter of sprintf
.
The code works well and does what is expected of our compiler and our tests.
Assuming the size of the array is not exceeded. And that whenever you use query as a reading parameter, it is the first parameter after formatting and the format begins with "% s".
Is it a correct use? Or is there a situation where it could go wrong?