字符串截取

因为不是科班出身,c语言字符串处理一直是我比较头痛的事。

没办法,多练习吧!

提取user后面, ':' 之前的字符串:

比如 "user:admin:passwd:123456;"

1、如果是从文件中取的话,取到缓存buff中,

  fgets(buff, buffsize, fd);

2、定位指针到user之后,

  char *p;

  p = strstr(user, buff);

  p += strlen(user);

3、取出"admin",

  while(buff[p] != ':')

  {

    temp[i++] = buff[p];  //temp中即为admin;

  }

原文地址:https://www.cnblogs.com/flash610/p/String_intercept.html