What happened to the next code fragment that the program worked - give a segmentation error. I am using gcc.
uint8_t result = 1 InsertRow("Name","Details of work",result); void InsertRow(char *Name, char *Description,uint8_t Result) { char Buffer[500]; if(Result==1) sprintf(Buffer,"<tr><td>%s </td> <td> %s </td> <td> %s </td></tr>",Name,Description,Result); }
You use the format specifier %sfor the type argument uint8_t, it should be %u, and you must specify a value unsigned intto match. This saves you from having to worry about the exact type and adjust the formatting (as commentators point out).
%s
uint8_t
%u
unsigned int
In addition, it is difficult for us to understand that the buffer is large enough, of course. If you have this, you can use snprinf()it to avoid it.
snprinf()
Here
sprintf(Buffer,"<tr><td>%s </td> <td> %s </td> <td> %s </td></tr>",Name,Description,Result);
Result ( uint8_t) char
Result
, , , , - , . . %s ,
. %d , uint8_t , int ( , ). %d, Result int ((int)Result)
%d
int
(int)Result
The result is not char *, you probably want% d for this