C和指针课后习题

 
 
#include <assert.h>
#include <stdio.h>


#define NULL 0 
#define NUL '\0'
#define TRUE 1
#define FALSE 0

char *match( char *str, char *want )
{

	while( *want != NUL )
		if( *str++ != *want++ )
			return NULL;
	return str;
}

int del_substr( char *str, char  *substr )
{
	char *next;
	while( *str != NUL ){
		next = match( str, substr );
		if( next != NULL )
			break;
		str++;
	}
	if( *str == NUL )
		return FALSE;
	while( *str++ = *next++ )
		;
	return TRUE;
}
int main()
{
	int del_substr( char *str, char  *substr );
	char *match( char *str, char *want );
	char src[20] = "ABCDEF";
	char str[] = "CD";
	int number=0;
	number =del_substr(src,str);
	if (number==NULL)
	{
		printf("Not find!");
	}
	else
	{
		printf("%s",src);
	}
	
	return 0;
}
刚开始看指针,觉得很迷糊,match函数已经改变了str的指针值,怎么在del函数中,没有改变。想了一下,应该会是形参和实参的概念不清楚吧。

你可能感兴趣的:(指针,形参与实参,修改内容)