finds the alpha character string in C.
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
// Finds the next alpha sequence
// @length, the length of the alpha string,
// @returns the pointer to the start of the string.
static const char*
find_alpha_str(const char* string, long* length) {
int on = 0;
const char* start = NULL;
while(*string)
{
if(on)
{
if(!isalpha(*string)) return start;
else *length += 1;
}
else
{
if(isalpha(*string))
{
on = 1;
*length = 1;
start = string;
}
}
string++;
}
return start;
}
int main(void) {
long le = 0;
const char * result = find_alpha_str(" \n\nfdsf", &le);
printf("length of alpha is %ld, str is %s\n", le, result);
return 0;
}