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
*  
*
*/



#include<stdio.h>
#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++) {
                        if(s1[i]==s2[j])
                                s1[i]=' ';
                }
        return s1[i];
        }
}

Recommended Answers

All 2 Replies

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.