char s1[] = "abracadabra"; // String
char a = 'a'; // Character
printf("The string is \"%s\" with %s.\n", s1, a);
rmchr(s1, a);
printf("The string is \"%s\" without %s.\n", s1, a);
system("pause");
return 0;
}
void rmchr(char s1[], char a) // Remove 'a' from the string 's'
{
int var = 0; // Counter variable for string 'temp'
int skip = 0; // Counter for skipped spaces
char *ptr = s1 + var; // Pointer to traverse array
char *sptr = ptr + skip; // Pointer for skipped spaces
while(*ptr != '\0')
{
while (*ptr != a)
*ptr = *sptr;
skip++;
var ++;
} //while
} // void
so i basically need to remove the charecter 'a' from abracadabra so after i remove 'a' its should be "brcdbr". i cant get this to compile. please help remember this is in C not C++
printf("The string is \"%s\" with %s.\n", s1, a);
This should be
printf("The string is \"%s\" with %c[/c].\n", s1, a);
You're passing a [b]character, not a C string.
Other than that, the compiler doesn't complain.
I think you have a logic error there, though.