Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
utils.cpp@7:7b225c565fe6, 2020-02-24 (annotated)
- Committer:
- bvirk
- Date:
- Mon Feb 24 14:34:14 2020 +0000
- Revision:
- 7:7b225c565fe6
- Child:
- 9:d15f84b277f3
ref to github in readme
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bvirk | 7:7b225c565fe6 | 1 | #include "MicroBit.h" |
bvirk | 7:7b225c565fe6 | 2 | #include "cppNorm.h" |
bvirk | 7:7b225c565fe6 | 3 | |
bvirk | 7:7b225c565fe6 | 4 | string trailedWith(const string src, char trailChar, int length) { |
bvirk | 7:7b225c565fe6 | 5 | if (length <= src.length()) |
bvirk | 7:7b225c565fe6 | 6 | return src; |
bvirk | 7:7b225c565fe6 | 7 | char buf[length+1]; |
bvirk | 7:7b225c565fe6 | 8 | memcpy(buf,src.toCharArray(),src.length()); |
bvirk | 7:7b225c565fe6 | 9 | memset(buf+src.length(),trailChar, length-src.length()); |
bvirk | 7:7b225c565fe6 | 10 | buf[length]='\0'; |
bvirk | 7:7b225c565fe6 | 11 | return string(buf); |
bvirk | 7:7b225c565fe6 | 12 | } |