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.
Misc.cpp
- Committer:
- khaiminhvn
- Date:
- 2021-03-23
- Revision:
- 3:a1a820da71f6
- Parent:
- 2:31917884f2d4
- Child:
- 4:68ef570210d3
File content as of revision 3:a1a820da71f6:
#include "Misc.h"
//itos
string Misc::itos(int n){
string tmp;
char buffer[16];
sprintf(buffer,"%d",n);
tmp = buffer;
return tmp;
}
string Misc::itos(int n, int w){
string tmp;
char buffer[16];
sprintf(buffer,"%d",n);
tmp = buffer;
while(tmp.length() < w)
tmp += " ";
return tmp;
}
string Misc::itos(float n){
string tmp;
char buffer[16];
sprintf(buffer,"%d",(int)n);
tmp = buffer;
return tmp;
}
string Misc::itos(float n, int w){
string tmp;
char buffer[16];
sprintf(buffer,"%d",(int)n);
tmp = buffer;
while(tmp.length() < w)
tmp += " ";
return tmp;
}
//fill
void Misc::fill(int *arr, int val, int size){
for(int i = 0; i < size; i++)
arr[i] = val;
}