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.
Dependencies: EthernetInterface-FRDM HTTPClient-SSL R_BSP SDFileSystem TLV320_RBSP USBHost mbed-rtos mbed-src
getline.cpp
00001 00002 #include <mbed.h> 00003 00004 int getline(char *prompt, char *buff, int size) 00005 { 00006 int sz ; 00007 00008 printf("%s", prompt) ; 00009 for(sz = 0 ; (sz < size) && ((*buff = getchar()) != '\r'); sz++, buff++) { 00010 putchar(*buff) ; 00011 if(*buff == '\\') { 00012 if(++sz >= size)break ; 00013 *buff = getchar() ; 00014 putchar(*buff) ; 00015 switch(*buff) { 00016 case 'n' : 00017 *buff = '\n' ; 00018 break ; 00019 case 'r' : 00020 *buff = '\r' ; 00021 break ; 00022 case 't' : 00023 *buff = '\t' ; 00024 break ; 00025 case '\\': 00026 *buff = '\\' ; 00027 break ; 00028 default: 00029 buff[1] = buff[0] ; 00030 buff[0] = '\\' ; 00031 buff++ ; 00032 } 00033 } else if(*buff == '\b') { 00034 if(sz >= 2) { 00035 buff-=2 ; 00036 sz-=2; 00037 } 00038 } 00039 } ; 00040 putchar('\n') ; 00041 *buff = '\0' ; 00042 return sz ; 00043 }
Generated on Fri Jul 15 2022 04:07:23 by
1.7.2