Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8568835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:11:52+00:00 2026-06-11T18:11:52+00:00

/* squeeze: delete all c from s */ void squeeze(char s[], int c) {

  • 0
/* squeeze: delete all c from s */
void squeeze(char s[], int c)
{
  int i, j;
  for (i = j = 0; s[i] != '\0'; i++)
    if (s[i] != c)
      s[j++] = s[i];
  s[j] = '\0';
}

int main(void)
{
  squeeze("squeeze", 'z');
  return 0;
}

I compiled it with gcc and ran it, and got a segmentation fault as a result.
Anything wrong with this example?

thanks to men,i have just made a usual mistake.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:11:53+00:00Added an answer on June 11, 2026 at 6:11 pm

    Your example shows that you’re trying to apply squeeze() to a string literal ("squueze"). This is not correct, since string literals are not always modifiable so it’s invalid to try
    to modify them. You need to call it with a character array:

    #include <stdlib.h>
    
    int main(void)
    {
       char test[] = "squeeze";
    
       squeeze(test, 'z');
       return EXIT_SUCCESS;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running a debian stable ThinkPad X1 (1294-3QG) with exactly three packages from squeeze-backports
i'm trying to use the terminal from python VTE binding (python-vte from debian squeeze)
I've just set up my debian squeeze server. But now i got a little
I am currently using squeeze to remove two singleton dimensions from a matrix. The
I'm trying to run a native binary, compiled on my x86 Debian Squeeze box
I created my bootloader before 2 years under debian squeeze/stable with gcc 4.5. Now
I'm trying to squeeze each bit from an application I'm writing, I've already installed
In Visual Studio—my main squeeze for many years—I can press Ctrl+F to immediately search
I'm using gcc 4.4 on Debian squeeze. Consider the following code. #include <map> #include
I'd like to squeeze or compress the result hash value from MD5 or SHA1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.