This follows up on msg: sprintf arg restriction of 2/6/04 Per the manual, "the total number of bytes passed to scanf() is limited..." I want to check this. Is this equivalent to the total number of characters entered on a line being interpreted? My (C166 large model) call is expecting up to 8 arguments, from 2 - 6 chars each, plus commas and spaces. Must I therefore guarantee that the total number of characters does not exceed 40?
CmdCnt = sscanf(serInputBuf, "pnti,%c%f,%c%f,%c%f,%c%f,%c%f,%c%f,%c%f,%c%f", &Cmd[0], &CmdParm[0], &Cmd[1], &CmdParm[1], &Cmd[2], &CmdParm[2], &Cmd[3], &CmdParm[3], &Cmd[4], &CmdParm[4], &Cmd[5], &CmdParm[5], &Cmd[6], &CmdParm[6], &Cmd[7], &CmdParm[7]); a sample input string looks like: $PNTI, P1, V2, A1.000, ...
"I want to check this. Is this equivalent to the total number of characters entered on a line being interpreted?" I think not. I think it refers to the number of bytes in the actual parameter list - so a string uses 3 bytes, because it's passed as a Generic Pointer (see Manual).
My (C166 large model) call is expecting up to 8 arguments This limitation applies only to the C51 tools. It does not apply to the C166 tools. And, it refers to the number of bytes of stuff passed to the functions. For example, a pointer to a string counts as 3 bytes and not as the length of the string. Jon
I'm working both with the C51 and C166, so I would like to understand the limit anyway. (Oddly, in my C166 book v9.00 it does list this restrictions paragraph; perhaps it's out of date.) so, if each string becomes a pointer:
sscanf(serinbuf,"hello %c%f,%c%f", &Cmd[0],&CmdParm[0]",&Cmd[1],&CmdParm[1])
The number of bytes passed to sscanf for this example:
sscanf (serinbuf, "hello %c%f,%c%f", &Cmd[0], &CmdParm[0], &Cmd[1], &CmdParm[1]);
3 for serinbuf (a char *) 3 for the "hello..." string 3 for &Cmd[0] (it's a pointer) 3 for &CmdParm[0] (it's a pointer) 3 for &Cmd[1] (it's a pointer) 3 for &CmdParm[1] (it's a pointer) --- 18