Hey guys,
if you're given a string..what kind of function would you write to delete its first element in C.
Thanks
Hey guys,
if you're given a string..what kind of function would you write to delete its first element in C.
Thanks
Hi Try This code Out...
void delfirstchar(char *str)
{
int i;
char *st;
str++;
while(*str!='\0')
{
*st=*str;
st++;
str++;
}
*st='\0';
str=st;
}
and lemme know if u have a problem.
Initially you send the string into Str. then eliminating the first character, the others are entered into another string st. Finally you close st and then reassign st to str.
Thats the whole idea.
Regards
Help everyone you can
Or just with a loop:
Code:for(i=0;i<strlen(string);i++) string[i]=string[i+1];