it helps to know how to read and under stand warnings and errors but I do not use code blocks anymore so I forget how they display theres,
Code:
gcc -Wall -Wextra -Wpedantic -lm -o "term2" "term2.c" (in directory: /home/userx/bin)
term2.c: In function 'removeChar':
term2.c:9:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
char *src, *dst:
^
term2.c:12:26: warning: statement with no effect [-Wunused-value]
for (src = dst =str; *src != '\0'; src++){
^
term2.c:12:45: error: expected ';' before ')' token
for (src = dst =str; *src != '\0'; src++){
^
term2.c:12:45: error: expected statement before ')' token
term2.c:13:10: error: 'dst' undeclared (first use in this function)
*dst = src;
^
term2.c:13:10: note: each undeclared identifier is reported only once for each function it appears in
term2.c:6:23: warning: unused parameter 'str' [-Wunused-parameter]
void removeChar(char *str, char garbage) {
^
Compilation failed.
you code
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void removeChar(char *str, char garbage) {
char *src, *dst: //< what the hell is that a colon or semi colon?, hummm I wonder.
for (src = dst =str; *src != '\0'; src++){
*dst = src;
if (*dst != garbage) dst++;
}
*dst = '\0';
}
int main(void)
{
char* str = malloc(strlen("HappyHolidays")+1);
strcpy(str, "HappyHolidays");
removeChar(str, 'H');
printf("%s", str);
free(str);
return 0;
}
sometimes I even see my errors in the code after I post and look at it, getting a different perspective on it then wonder why I cannot just delete that mistake from my life.
here is another one of your mistakes
Code:
1
Write a function named remove()
what is your function called? Pay attention to details I am sure your instructor will mark you on it. I know I would.