LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

what's difference between scan and sscanf

Solved!
Go to solution

when get result from instrument,I find RS give us two function,

 one:

  if ((status  = viRead (instrSession, buf, 50, &retCnt)) < 0)
         return status;
     if (Scan(buf, "%s>f%",MaxBurstPower) != 1)
         return  MB8820B_status; 

   return MB8820B_status; 
       
}

Two:
  if (strcmp (rdBuf, "NAN") != 0)
    sscanf (rdBuf, "%lf", MaxBurstPower);
anyone can tell me the difference between them,if use scan() get result from instrument,the up way is right?

0 Kudos
Message 1 of 3
(3,689 Views)
Solution
Accepted by topic author sean_tan
Scan and sscanf are very similar in usage (infact most of the formatting string can be passed from one instruction to the other). The main difference is that Scan comes form a proprietary library from NI, so that if you want to write code portable across multiple compilers you should not use it. I find Scan more powerful in some particular occasions, for example when scanning with fixed number of bytes per digit and so on. The same facilities in my opinion can be obtained with sscanf in more difficult way.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 3
(3,674 Views)
thanks Robert.
0 Kudos
Message 3 of 3
(3,653 Views)