#include
#include
#include
#define MAX_LINE_LEN 256
#define NULL_TERM '\0'
/* A function that will print the content of the token_list */
int printcharlist(char **tok_list)
{
char **pptr = tok_list;
while (*pptr) {
printf ("++ %s\n", *pptr);
pptr++;
}
return 0;
}
/* returns the string between 2 pointers (not forgetting to append NULL_TERM */
char *getStr(char *start, char *end)
{
int length=end-start;
int i=0;
char *result = (char *)malloc (sizeof (char) * (length+1));
while (i < length) {
result[i] = *start;
start++;
i++;
}
result[i] = NULL_TERM;
return result;
}
Proggramming Tutorials & Web Development Technologies - Tutorials for PHP,Laravel,Codeigniter,Yii,Bootstrap,Ajax,JQuery
Tuesday, 19 August 2014
Splitting a string into tokens in C
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment