I assume that the string is stored in a char array and '$' comes first while traversing array from left to right.
Here is the simple C code:
int i, length = 0;
printf("Enter a string \n");
for(i=0; string[i] != '$'; i++);
/* keep going through each character of the string till '#' encounters*/
for (++i; string[i] != '#'; i++)
printf("The length of a string between the special characters is %d \n", length);
Thanks & Regards
thank you Abhinav.