example program to print out "Hello World!" to the terminal
Description
This example is to demonstrate printing "Hello World!" to the command line. The printf statement can be very useful for debugging.
Examples
%c is used to print characters
// initialize some characters
char x = 'a';
char y = 'b';
char z = 'c'
// print characters to terminal
printf("characters: %c,%c,%c",x,y,z); // would print 'characters: a,b,c'
%d is used to print integers
// initialize integer with value 42
int x = 42;
printf("The answer is %d",x); // would print 'The answer is 42'
%f is used to print floating point numbers
// initialize pie with value 3.14
float pie = 3.14;
printf("pie = %f ",pie); // would print 'p = 3.14'
Revision 2:b0ec6da021f0, committed 2014-11-24
- Comitter:
- mbedAustin
- Date:
- Mon Nov 24 18:58:05 2014 +0000
- Parent:
- 1:039688a53fff
- Commit message:
- have a commit message that makes sense. This commit added a space for demonstration purposes.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Nov 24 18:53:35 2014 +0000
+++ b/main.cpp Mon Nov 24 18:58:05 2014 +0000
@@ -2,7 +2,7 @@
// This program prints "Hello World" to the terminal
//
#include "mbed.h"
-
+
DigitalOut led(LED1);
int main() {