Jump to content

C Defining Data Arrays And Not BSS Arrays?

- - - - -

  • Please log in to reply
1 reply to this topic

#1
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,254 posts
  • Location:C:\Countries\US
How do I tell C to define the array in the .data section, and not the .bss section?

I tried this:
char source[16344]; 
But it seems to define `source` inside the .bss section; that's not what I want.

It's just not practical to use this char source []= {0, 0, 0, ... kind of definition, due to the size of the array.

---------- Post added at 10:47 AM ---------- Previous post was at 10:21 AM ----------

Oh, {} syntax doesn't have to include all the entries; that's nice.

Nice thing there's this page:
How to initialize an array in C - Stack Overflow

char source [16344]= {0}; 

It works now.

#2
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,719 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
Interesting - I didn't know you could do the {0} thing...and I've been programming in C for nearly 8 years now. :D
sudo rm -rf /




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users