Created
October 21, 2014 17:43
-
-
Save Niceblack/da921b1f808ceb014d62 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Разбор строки на лексемы/токены | |
#include <stdio.h> | |
#define BUF 128 | |
int is_delimiter(char c) | |
{ | |
return (c == ' ' || c == '\t'); | |
} | |
int main() | |
{ | |
char string[] = "Help me 123456789", *c = string; | |
char buf[BUF] = {0}, *b = buf; | |
while (1) { | |
if (!is_delimiter(*c) && *c != '\0') | |
*(b++) = *c; | |
else if (buf != b) { | |
*b = '\0'; | |
printf("%s\n", buf); | |
b = buf; | |
*b = '\0'; | |
} | |
if (*(c++) == '\0') break; | |
} | |
printf("\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment