Delete specified in the string *

    Assuming that the input string contains only letters and an asterisk. Please write function fun, which is: in addition to the tail of an asterisk, to delete all the characters in the other asterisk. 
    P is pointing to the last parameter in a string of letters. When writing a function, not use string functions C language provides. 
#include <stdio.h> 
void Fun (a char [], char * p) 
{ 
	char * CH = p; 
	p = a; // to point p a 
	the while (! * a = CH) // iterate to a final a letter, if not * to be assigned to P 
	{ 
		IF (! * a = '*') 
		{ 
			* P ++ = * a; 
		} 
		a ++; 
	}	 
	the while (! * a = '\ 0') // the remaining values assigned to P 
	{ 
		* P ++ = * a ++; 
	} 
	a = P; 
	* (a ++) = '\ 0'; // be a last character set '\ 0' 
} 
void main () 
{ 
	char S [81], * P ; 
	P = S; 
	the printf ( "Please INPUT A String:"); 
	the gets (S); 
	the while (! * P = '\ 0') P ++;
	while (* p == '*' ) p--; // pointer to the last letter p 
	Fun (S, p); 
	for (int I = 0;! S [I] = '\ 0'; I ++) 
		the printf ( "% C", S [I]); 
	the printf ( "\ n-"); 
}

  

Guess you like

Origin www.cnblogs.com/-slz-2/p/11373430.html