sscanf problem when giving a string containg % as the first parameter.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

sscanf problem when giving a string containg % as the first parameter.

1,629 Views
JaimeR
Contributor III

I need to perform the following instructions into MQX. I need to get the four ip numbers into four integers(a,b,c,d).

Problem is I am receiving %2E  as the  "."  and the "%" symbol is giving me a lot of trouble. I have tested those lines into a C compiler for PC  applications and it works fine but it fails in MQX.

 

char ip[] = "192%2E168%2E0%2E120";

sscanf(ip, "%d%%%*[2E]%d%%%*[2E]%d%%%*[2E]%d" , &a, &b, &c, &d);

 

* Function Name    : _io_sscanf
* Returned Value   : _mqx_int
* Comments         :
*   This function performs similarly to the 'C' sscanf function.
*   See scanline.c for comments.
*   The function returns the number of input items converted and assigned}

 

Where do I find scanline.c file in order to see the comments?

I need to see what does the sscanf function can do in order to get this working.

Let me know if someone knows a way around this.

 

Thanks in advanced.

0 Kudos
Reply
3 Replies

926 Views
PetrM
Senior Contributor I

You can find the right file here:

 

mqx/source/fio/io_scanl.c

 

Sorry for bad comment.

 

PetrM

 

0 Kudos
Reply

926 Views
JaimeR
Contributor III
Do you know how can I catch a "%" symbol?
0 Kudos
Reply

926 Views
PetrM
Senior Contributor I

Sorry to say that, but there seems to be no support for '%' escaping.

Please consider input preprocessing (replace %2E with something sscanf knows).

 

0 Kudos
Reply