Skip to content

Instantly share code, notes, and snippets.

@Niceblack
Created October 21, 2014 17:43
Show Gist options
  • Save Niceblack/da921b1f808ceb014d62 to your computer and use it in GitHub Desktop.
Save Niceblack/da921b1f808ceb014d62 to your computer and use it in GitHub Desktop.
// Разбор строки на лексемы/токены
#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