使节点的混合大小写值全部小写(C)
Making a node's mixed case value to all lowercase (C)
这段代码的目标是遍历我传入的链表并将子字符串与字符串进行比较以确定它是否在其中。如果子字符串在字符串中,则打印该行。不幸的是,如果子字符串是 foo 而字符串是 "ConFoosing",它不会认为它是匹配的,我怎样才能使 "tester",我的行在比较之前都是小写的? toLower() 不会在 char * 上工作,我不确定如何将 char* 转换为 char str[]
static int wordMode(struct node *head, char* word)
{
struct node *ptr;
int count = 0;
printf("word count\n");
for (ptr = head; ptr != NULL; ptr = ptr->next){
char * tester = ptr->filler;
char *pch = strstr(tester, word);
if(pch){
printf("LINE: %s\n", tester);
count++;
}
printf("%d", count);
}
}
我使用 strcastrate 来解决它,示例和文档可以在这里找到
这段代码的目标是遍历我传入的链表并将子字符串与字符串进行比较以确定它是否在其中。如果子字符串在字符串中,则打印该行。不幸的是,如果子字符串是 foo 而字符串是 "ConFoosing",它不会认为它是匹配的,我怎样才能使 "tester",我的行在比较之前都是小写的? toLower() 不会在 char * 上工作,我不确定如何将 char* 转换为 char str[]
static int wordMode(struct node *head, char* word)
{
struct node *ptr;
int count = 0;
printf("word count\n");
for (ptr = head; ptr != NULL; ptr = ptr->next){
char * tester = ptr->filler;
char *pch = strstr(tester, word);
if(pch){
printf("LINE: %s\n", tester);
count++;
}
printf("%d", count);
}
}
我使用 strcastrate 来解决它,示例和文档可以在这里找到