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 6579381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:53:27+00:00 2026-05-25T15:53:27+00:00

Consider the function: char *func() { return Some thing; } Is the constant string

  • 0

Consider the function:

char *func()
{
    return "Some thing";
}

Is the constant string (char array) "Some thing" stored in the stack as local to the function call or as global in the heap?

I’m guessing it’s in the heap.

If the function is called multiple times, how many copies of "Some thing" are in the memory? (And is it the heap or stack?)

  • 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-05-25T15:53:28+00:00Added an answer on May 25, 2026 at 3:53 pm

    String literal “Some thing” is of type const char*. So, they are neither on heap nor on stack but on a read only location which is a implementation detail.

    From Wikipedia

    Data

    The data area contains global and static variables used by the program
    that are initialized. This segment can be further classified into
    initialized read-only area and initialized read-write area. For
    instance the string defined by char s[] = “hello world” in C and a C
    statement like int debug=1 outside the “main” would be stored in
    initialized read-write area. And a C statement like const char* string
    = “hello world” makes the string literal “hello world” to be stored in
    initialized read-only area and the character pointer variable string
    in initialized read-write area. Ex: static int i = 10 will be stored
    in data segment and global int i = 10 will be stored in data segment

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

Sidebar

Related Questions

Consider this code: const char* someFun() { // ... some stuff return Some text!!
Consider the following function: void f(const char* str); Suppose I want to generate a
Consider such function: function Test($foo, $bar) { ... } We can call it: Test
consider a function like char* strcpy (char* destination, const char* source); The given value
Consider the following function: char *f() { char *s=malloc(8); } main() { printf(%c,*f()='A'); }
Consider these two function definitions: void foo() { } void foo(void) { } Is
Consider the delegate for a generic A to B function: public delegate B Fun<A,
Let's consider the following scenario: a function which can generate code colors from white
Howdy. Consider the following: SQL> DECLARE 2 b1 BOOLEAN; 3 b2 BOOLEAN; 4 FUNCTION
Consider: List<String> someList = new ArrayList<>(); // add "monkey", "donkey", "skeleton key" to someList

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.