Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 9th, 2005, 03:34 PM
Authorized User
 
Join Date: Jan 2005
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default creating an array of size 2^16 bits

Hi,

i am very new to c programming and was wondering if someone could help me. i am using linux and i am trying to create an array of type unsigned short and of size 2^16 (400000 bits) in my c program. does anybody know how to do this?

i tried the following code:

unsigned short result[];

i didn't know how to specify the size. can anyone help?

Thanks in advanced.

s

Reply With Quote
  #2 (permalink)  
Old November 9th, 2005, 06:48 PM
Authorized User
 
Join Date: Nov 2005
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the size goes in the square brackets, and it is not in bytes or bits but in the number of unsigned integers that you wish to store in that array.

Reply With Quote
  #3 (permalink)  
Old November 9th, 2005, 08:59 PM
Authorized User
 
Join Date: Nov 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Paramesh
Default

You should declare the array like this:

unsigned short result[10];

where 10 is the size of the array.

"Don't walk behind me; I may not lead.
 Don't walk in front of me; I may not follow.
 Just walk beside me and be my friend."
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
Label Array With Dynamic Size nevincm C# 1 April 13th, 2007 11:24 AM
size of the array mafia boy Java Basics 6 April 24th, 2006 07:41 PM
creating array hiruni Beginning VB 6 5 February 9th, 2006 03:22 AM
A subscript must be between 1 and size of array raj03 Crystal Reports 1 July 8th, 2004 02:12 PM
increase the size of the array Beulah ASP.NET 1.0 and 1.1 Basics 1 September 12th, 2003 08:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.