473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

int *x=new int[38200]; is this correct??

25
Hello,
I have done the following initialization in my C++ code:
int *x=new int[38200];
However a doubt arouse to me now..... int can take values only from 2^15 to (2^15)-1..........So do i have to change it to something like
long int *x=new long int[38200] or is it ok coz its allocating dynamic memory?? If I have to change, then what should it be i.e is my new initialization correct?
Thanks,
prads
Nov 18 '07 #1
1 1318
oler1s
671 Expert 512MB
Whoa, stop. Let's get something straight. The 38200 is an argument to new. For example, you quite often have character pointers. Does that mean you can't have char *str = new char[1024]? Obviously not. The 1024 has nothing to do with char. It just specifies how many of the type to allocate.

If you want 38200 ints, say so. By the way, a size won't be negative, so even if the size were limited to an integer, it would be an unsigned int, so that's 2^16-1. But the parameter for new is size_t . size_t is probably much bigger than a uint on your system though.
Nov 18 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Akyl Tulegenov | last post by:
Dear All! this is a construct I use to create the tensor of rank 2 in C. double **dtensor2(long nl1,long nh1,long nl2,long nh2){ double **tensor=NULL; long i1,i2; tensor=(double...
6
by: Alfonso Morra | last post by:
I have written the following code, to test the concept of storing objects in a vector. I encounter two run time errors: 1). myClass gets destructed when pushed onto the vector 2). Prog throws a...
7
by: vikky | last post by:
hi all, Out of sheer curosity, I decided to initialize an integer with a number bigger than INT_MAX, however I still am not able to justify its output. Here is the program : #include<stdio.h> ...
8
by: 2G | last post by:
Hi, Could anyone give me a hint how to generate this using codedom, I know how to generate properties and methods .... but this I can't seem to find :s. public int this { get { }
0
by: avakharia_ibsdev | last post by:
Hello all, I am not much familier with Web Applications. I am basically a C++,VC++ programmer. I have one query.. I want to open a number of child pages from one page let's say Parent Page....
318
by: jacob navia | last post by:
Rcently I posted code in this group, to help a user that asked to know how he could find out the size of a block allocated with malloc. As always when I post something, the same group of people...
11
by: mast2as | last post by:
This question has been posted to this forum before and I read the thread but found that the answers were perhaps imcomplete, so I am trying again. Whenever I am creating objects I would like to...
6
by: jt | last post by:
#include <stdio.h> void f(); int main() { long int i; i=20; f(); i = 10; printf ("\n%d\n",i);
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.