Skip to content

Instantly share code, notes, and snippets.

@OctoberWu
Created August 29, 2018 13:51
Show Gist options
  • Save OctoberWu/fb72aea8569954543eadd0eb3ca683bb to your computer and use it in GitHub Desktop.
Save OctoberWu/fb72aea8569954543eadd0eb3ca683bb to your computer and use it in GitHub Desktop.
#string_operation
/*
============================================================================
Name : findLastof.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(void) {
char *path = "/dev/ttyS2";
char *pch;
pch = strstr(path, "ttyS");
//if(pch != NULL){
//pch = strchr(pch+1, 'S');
//}
//pch = pch + 3;
int ret;
pch += strlen("ttyS");
//printf("this is %s\n", pch);
//if(isdigit(*pch))
// puts("I am digits\n");
printf("strstr: %s\n", pch);
ret = atoi(pch);
printf("The Integer: %d\n", ret);
puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment