deleting string...
example:
deleting...

enter string: the quick brown fox and the lazy dog.
enter string to delete: the(the first one)
new string: quick brown fox and the lazy dog.

pls. help me in how to program that...

pls. help me in how to program that...

char str[]="the quick brown fox and the lazy dog" ;
int i =0;
while(str[i] !=' ' )
 i++;
strcpy(str,str+i+1);

works if the above is your requirement, analyze it yourself.
happy learning...........

char str[]="the quick brown fox and the lazy dog" ;
int i =0;
while(str[i] !=' ' )
 i++;
strcpy(str,str+i+1);

works if the above is your requirement, analyze it yourself.
happy learning...........

Spot the undefined behavior in the above code. Happy learning! ;)

commented: Nice :) +19

Spot the undefined behavior in the above code. Happy learning! ;)

i dint see any undefined behaviour statements in the code.

can you please spot it.

strcpy(str,str+i+1);

The strcpy function copies the string pointed to by s2 (including the terminating null character) into the array pointed to by s1. If copying takes place between objects that overlap, the behavior is undefined.