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

  • SEARCH
  • Home
  • 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 8917553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:31:06+00:00 2026-06-15T05:31:06+00:00

Hello i am writing a program and i have declared a string in this

  • 0

Hello i am writing a program and i have declared a string in this way:

char *string=malloc(sizeof(char));

In my laptop i am using 64 bit Mint OS and everything is working fine.However in a 32 bit Debian machine i get in that line of code a segmentation fault.If i declare the string without malloc,like this: char string[100] the program is working fine.When i run the program with GDB it says malloc.c not found or something like that.Is this behavior logical?If someone has experienced the same issue before can please explain me why its happening?Thanks in advance.

  • 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-15T05:31:08+00:00Added an answer on June 15, 2026 at 5:31 am

    Adding to the other answer, I try to explain why it fails on 32 bit, but succeeds on 64 bit:

    Most probably, your memory manager works with a certain granularity which depends on the word size of your system. Maybe it is 4 bytes on a 32 bit system and 8 bytes on a 64 bit system. (I am not sure if this is correct, however.)

    If you allocate 1 byte, there are 3 resp. 7 bytes which are not used. So while you are not allowed to use them, nothing will happen.

    If you use more than 3, but up to 7 bytes of them, nothing will happen on a 64 bit system, but on a 32 bit system, the program crashes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have a chunk of memory (allocated with malloc()) that contains bits (bit
Hello I am writing this program, and I am trying to figure out how
This is a program I'm writing that's supposed to display some text in a
SOLVED see Edit 2 Hello, I've been writing a Perl program to handle automatic
Before writing this program,I thought that our is a package scope variable and my
This is a homework assignment, I have to write a program that reads a
I have a simple Linux C program that I'm writing to help me better
I am writing a service using wcf. I have created a solution with two
Hello I am new to programming and I am writing a program in C.
I have the following problem: I am writing a C++ program that has to

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.