Created
August 29, 2018 13:48
-
-
Save OctoberWu/97d92c50517c8ae88144f4b045f1cb11 to your computer and use it in GitHub Desktop.
#C #string_operation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
============================================================================ | |
Name : string_C.c | |
Author : octoberwu | |
Version : | |
Copyright : Your copyright notice | |
Description : Hello World in C, Ansi-style | |
============================================================================ | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int main(int argc, char* argv[]) { | |
//puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */ | |
//return EXIT_SUCCESS; | |
strSPNex(); | |
return 0; | |
} | |
void strSPNex(){ | |
char *str = "First test string"; | |
char *str1 = "1t7543h90"; | |
char *reg1 = "test"; | |
char *reg2 = "i1"; | |
char *reg3 = "0123456789"; | |
size_t n; | |
printf("str : %s\n",str); | |
printf("reg1 : %s\n",reg1); | |
printf("reg2 : %s\n",reg2); | |
n = strspn(str,reg1); | |
printf("First occurrence of char from reg1 on\n\t\ | |
position %d\n",n); | |
n = strcspn(str,reg2); | |
printf("First occurrence of not char from reg2 on\n\t\ | |
position %d\n",n); | |
n = strspn(str1, reg3); | |
printf("xxxFirst occurrence of not char from str1 on\n\t\ | |
position %d\n",n); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment