Hi everybody,

I just start lerning C
I'v heard a lot about pointers but not really sure were to put them.

(or may be I'm wrong may be I just made some mistake) pls take a quic look.

/* This program will delete all simbols
*  from s1 that s2 contains

#define SIZE 100
void squeeze(char s1[], char s2[]);

int main() {
        char s[SIZE] = "Hi my name is Sean, I like C, and I really like girls";
        char j[SIZE] = "replace";

        printf(s + '\n');
        squeeze(s, j);
 printf(s + '\n');
return 0;

char squeeze(char s1[], char s2[]) {
        int i=0;
        int j=0;

        for(i=0; i<s1; i++) {
                for(j=0; j<s2 && s2[j]!='\0'; j++) {
                                s1[i]=' ';
        return s1[i];

Edited by shean1488: n/a

5 Years
Discussion Span
Last Post by zeroliken

I'm not entirely sure what you're trying to accomplish with the squeeze function.
I will tell you this:
Instead of

for(i=0; i<s1; i++) {

you probably want

for(i=0; i<strlen(s1); i++) {

strlen requires string.h, not to be confused by the C++ string header.


you declared the function's data type as void in the function prototype yet you declared it as a char

Edited by zeroliken: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.