c语言中字符串的截取

Python038

c语言中字符串的截取,第1张

char *p = “/home/c/aa.txt”

char *q

q=strrstr(p,"/")

q++

q = NULL

p 此时就截取文件路径了。

条件是xxx中不包含b

#include<stdio.h>

void f(char *a,char *b)

{ while ( *a ) if ( (*a)=='a' ) break else a++

if ( (*a)=='a' )

{ a++

while ( *a ) { if ( (*a)=='b' ) break else (*b++)=(*a++) }

}

(*b)=0

}

void main()

{ char str[256],str1[256]

gets(str) f(str,str1) printf("%s\n",str1)

}