Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 6 months ago.
pc.printf a method?
If i make an object pc out of the class serial, you can find in the documentation this object has several methods: baud, format, readable, writeable, attach but there is nothing about printf and scanf. what are these then?? where do i find documentation about how i have to use these commands? thnx
1 Answer
11 years, 6 months ago.
Serial inherits the 'stream' interface and that provides the printf method. See the declaration of the Serial class.
I did find stream.h but i dont really understand why it is not just included in serial.h??
posted by 14 May 2013Inheritance is one of the great features of object oriented languages like C++. The stream methods are not included in serial to allow you to use them in other classes as well. They are for example also included in the TextLCD class and in my enhanced TextLCD class. All you need to do to make use of the powerful printf features is implement a putc() method in your own new class.
posted by 14 May 2013