int df_valid_test(struct mail_bodystruct *body, char *test) { int passed = 0; if(!(passed = !test)){ /* NO test always wins */ if(!*test){ passed++; /* NULL test also wins! */ } else if(body && !struncmp(test, "_CHARSET(", 9)){ char *p = strrindex(test, ')'); if(p){ *p = '\0'; /* tie off user charset */ if((p = parameter_val(body->parameter,"charset")) != NULL){ passed = !strucmp(test + 9, p); fs_give((void **) &p); } else passed = !strucmp(test + 9, "us-ascii"); } else dprint((1, "filter trigger: malformed test: %s\n", test ? test : "?")); } } return(passed); }
int test_strrindex(const char *s,char t) { printf("Last index of %c in %s is ",t,s); int retval = strrindex(s,t); printf("%d\n",retval); return 0; }
int main() { char s[] = "1234567896789"; char t[] = "789"; int postion = strrindex(s, t); printf("postion = %d", postion); exit(0); }
int main(void) { char s[] = "toronto"; char t[] = "to"; printf("%d\n", strrindex(s, t)); return 0; }
main() { char s[]="0123abc789abc345"; char t[]="abc"; printf("字符串%s在字符串%s中最右边出现的位置是:",s,t); int r=strrindex(s,t); printf("%d\n",r); }
void check(char t[], int expected) { printf("checking %s\n", t); int res = strrindex(str, t); if (res != expected) { printf("%d != %d\n", res, expected); exit(-1); } }
main(void) { char s[MAXLEN]; getlineKR(s,MAXLEN); printf("%d\n",strrindex(s,pattern)); return 0; }
int main() { char line[MAXLEN]; fgets(line, MAXLEN, stdin); printf("%d\n", strrindex(line, pattern)); return 0; }
int main() { char line[MAX_LINE_LEN]; int found = 0; int len = get_line(line, MAX_LINE_LEN); printf("Index: %i\n", strrindex(line, getchar())); }
char *dirname(const char *filename) { if (filename == NULL) return strdup("."); char *result = strdup(filename); int c = strrindex(result, '/'); while (c == strlen(result) - 1) { result[c] = '\0'; c = strrindex(result, '/'); } if (c < 0) return strdup("."); result[c] = '\0'; return result; }
int main(int argc, char* argv[]) { char x[] = "Hola, mundo"; char y[] = "mundo"; int salida = strrindex(x, y); printf("Pos: %d\n", salida); }
/* find all lines matching pattern */ int main(void) { char line[MAXLINE]; while (getline(line, MAXLINE) > 0) printf("%d\n", strrindex(line, ch)); return 0; }
char *basename(const char *filename) { if (filename == NULL) return NULL; char *result = strdup(filename); int c = strrindex(result, '/'); while (c == strlen(result) - 1) { result[c] = '\0'; c = strrindex(result, '/'); } if (c < 0) return result; else return result + c + 1; }
int main() { char a[]= "Hello World and Hello Universe"; char t; printf("Enter a character\r\n"); scanf("%c%*c",&t); printf("the letter %c occurs at the right most index %d\r\n",t,strrindex(a,t)); printf("in the string %s\r\n",a); return 0; }
int main() { char line[MAXLINE]; int found = 0; while (getl(line, MAXLINE) > 0) { if (strrindex(line, "abba") >= 0) { printf("%s", line); found++; } } return found; }
int main() { char line[MAXLINE]; int found = 0; while (Getline(line, MAXLINE) > 0) if (strrindex(line, pattern) >= 0) { printf("%s", line); found++; } return found; }
int test(char s[], char t[]) { char *p; int index; index = strrindex(s, t); p = strstr(s, t); if ((index == -1 && p == NULL) || (index == p+strlen(t)-1-s)) return 0; else return -1; }
int main(int argc, char* argv[]) { char s[MAXLINE]; char t[] = "char"; int pos; while(getline(s, MAXLINE) > 0) //printf("%s", s); if((pos = strrindex(s, argv[1])) != -1) { printf("%d:%s", pos, s); } return 0; }
int main() { char line[MAXLINE]; int found=0; int ind; while (getline(line,MAXLINE)>0) { if ((ind=strrindex(line, pattern))>=0) { printf("%s\n index:%d",line, ind); found++; } } return found; }
int main() { char s1[S1MAXLN]; char s2[S2MAXLN]; int p; printf("\npattern: "); getlinex(s2, S2MAXLN); printf("\ntext:\n"); while (getlinex(s1, S1MAXLN) > 0) if ((p = strrindex(s1, s2)) >= 0) printf("%sposition: %d\n", s1, p); return 0; }
int main(void) { char line[MAXLINE]; int found = 0; while (getline(line, MAXLINE) > 0) { int x = strrindex(line, pattern); //if (x >= 0) { printf("%d", x); found++; //} } return found; }
int main() { char text[MAX_STR_LEN] = "the quick brown fox jumped over the lazy dog"; printf("lazy: %d\n", strrindex(text, "lazy")); printf("the: %d\n", strrindex(text, "the")); printf("dog: %d\n", strrindex(text, "dog")); printf("fox: %d\n", strrindex(text, "fox")); printf("jump: %d\n", strrindex(text, "jump")); printf("e: %d\n", strrindex(text, "e")); printf("o: %d\n", strrindex(text, "o")); return 0; }
int main(void) { char s[] = "This is my test string, but its not much of a test string."; char t[MAX_STRING] = ""; (void)strcpy(t, "test"); printf("In the string: \"%s\"\n", s); printf("The leftmost occurrence of \"%s\" is at position %d.\n", t, strindex(s, t)); printf("The rightmost occurrence of \"%s\" is at position %d.\n", t, strrindex(s, t)); (void)putchar('\n'); (void)strcpy(t, "string"); printf("In the string: \"%s\"\n", s); printf("The leftmost occurrence of \"%s\" is at position %d.\n", t, strindex(s, t)); printf("The rightmost occurrence of \"%s\" is at position %d.\n", t, strrindex(s, t)); (void)putchar('\n'); (void)strcpy(t, "This"); printf("In the string: \"%s\"\n", s); printf("The leftmost occurrence of \"%s\" is at position %d.\n", t, strindex(s, t)); printf("The rightmost occurrence of \"%s\" is at position %d.\n", t, strrindex(s, t)); (void)putchar('\n'); (void)strcpy(t, "."); printf("In the string: \"%s\"\n", s); printf("The leftmost occurrence of \"%s\" is at position %d.\n", t, strindex(s, t)); printf("The rightmost occurrence of \"%s\" is at position %d.\n", t, strrindex(s, t)); (void)putchar('\n'); (void)strcpy(t, "not in string"); printf("In the string: \"%s\"\n", s); printf("The leftmost occurrence of \"%s\" is at position %d.\n", t, strindex(s, t)); printf("The rightmost occurrence of \"%s\" is at position %d.\n", t, strrindex(s, t)); return 0; }
char *buildpath(char *part1, char *part2) { if (part1 == NULL && part2 == NULL) return NULL; if (part1 == NULL) part1 = ""; if (part2 == NULL) part2 = ""; char *result = (char *) malloc(strlen(part1) + strlen(part2) + 2); int c = strrindex(part1, '/'); while (c == strlen(part1)) { part1[c] = '\0'; c = strrindex(part1, '/'); } c = strindex(part2, '/'); while (c == 0) { part2++; c = strindex(part2, '/'); } strcpy(result, part1); strcat(result, "/"); strcat(result, part2); return result; }
int main() { char line[MAX]; char search; int p; printf("Enter a line\n"); scanf("%s", line); printf("Enter a char that would like to search\n"); getchar(); scanf("%c", &search); p = strrindex(line, search); printf("%d", p); }
int main(int argc,char *argv[]) { char num; if(argc !=2) { printf("Uasge:xiaodong.out <string>"); return -1; } printf("The string you just input is:%s,\n",argv[1]); printf("Please input the char you want to search:"); num=getchar(); printf("The char you want to search is %c\n",num); strrindex(argv[1],num); }
int main() { char line[MAXLINE]; int found = 0; int found_loc = -1; while (my_getline(line, MAXLINE) > 0){ found_loc = strrindex(line, pattern); if (found_loc >= 0) { printf("%s", line); printf("%d\n", found_loc); found++; } } return found; }
main() { char str[] = "The cat in the hat loves green eggs and ham."; char find[][MAXSTRLEN] = { "cat", "hat", "eggs", "ham", "balls", "at"}; printf("%s\n\n", str); for (int i = 0; i < 6; i++) { int p = strrindex(str, find[i]); if (p >= 0) printf("Found '%s' at index %d\n", find[i], p); else printf("Couldn't find '%s' in the string.\n", find[i]); } printf("\n"); system("pause"); return 0; }
/* find all lines matching pattern */ main() { char line[MAXLINE]; int found = 0; int findindex; while (zagetline(line, MAXLINE) > 0) { if ( (findindex = strrindex(line, pattern)) >= 0) { found++; reverse(line); reverse(pattern); printf("The start index of the right most instance of:\n"); printf("%s\n", pattern); printf("in line:\n"); printf("%s",line); printf("is %d\n", findindex); } } return found; }
int main() { char s[] = "this is a test!"; char t[] = "is"; printf("%d\n", strrindex(s, t)); }