Declare an array in the BSS segment

This is a discussion on Declare an array in the BSS segment within the C Programming forums, part of the General Programming Boards category; How do I declare a variable so that it gets placed in the BSS segment instead of on the stack/in ...

  1. #1
    FOX
    Join Date
    May 2005
    Posts
    188

    Declare an array in the BSS segment

    How do I declare a variable so that it gets placed in the BSS segment instead of on the stack/in the data segment?

    Code:
    int a; /* Data segment? */
    static int b; /* Data segment? */
    char buf1[10]; /* Data segment? */
    static char buf2[10] /* Data segment? */
    
    int main(void)
    {
            int c; /* Stack? */
            static int d; /* Data segment? */
            char buf3[10]; /* Stack? */
            static char buf4[10] /* Data segment? */
    
            return 0;
    }

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    The data segment contains variables that were initialized to some value. The BSS segment is where uninitialzed data is stored.
    Code:
    int a;//BSS segment
    int b=1;//data segment
    Same thing for static variables.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 2d array question
    By gmanUK in forum C Programming
    Replies: 2
    Last Post: 04-21-2006, 01:20 PM
  2. question about multidimensional arrays
    By richdb in forum C Programming
    Replies: 22
    Last Post: 02-26-2006, 09:51 AM
  3. [question]Analyzing data in a two-dimensional array
    By burbose in forum C Programming
    Replies: 2
    Last Post: 06-13-2005, 08:31 AM
  4. Type and nontype parameters w/overloading
    By Mr_LJ in forum C++ Programming
    Replies: 3
    Last Post: 01-02-2004, 01:01 AM
  5. how do i declare array of pointers to base clase reobject
    By icantprogram in forum C++ Programming
    Replies: 3
    Last Post: 12-20-2002, 02:30 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21