Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


I use turbo C which allocates 2 bytes for integers and 4
bytes for long. I tried to declare array of size 500000 of
long type using the following code...

long *arr;
arr=(long *)(malloc)(500000 * sizeof(long));

It gives a warning that "Conversion may lose significant
digits in function main"...

And the resulting array size was very less around 8400 as
compared to 500000. Any suggestions will be welcomed....

Answers were Sorted based on User's Feedback



I use turbo C which allocates 2 bytes for integers and 4 bytes for long. I tried to declare array ..

Answer / anshu ranjan

I want to make a point here...I am not sure whether there is a limit to amount of memory that you can allocate using malloc...

I used this code in a program and it ran perfectly fine...

--------------
char **a;
int **val;

a =(char **) malloc ( 1000 * sizeof *a );
for ( i = 0; i < 1000; i++ )
a[i] =(char *) malloc ( 1000 * sizeof *a[i] );
val =(int **) malloc ( 1000 * sizeof *val );
for ( i = 0; i < 1000; i++ )
val[i] =(int *) malloc ( 1000 * sizeof *val[i] );

---------------

Is This Answer Correct ?    1 Yes 0 No

I use turbo C which allocates 2 bytes for integers and 4 bytes for long. I tried to declare array ..

Answer / vignesh1988i

good morning to you.....


here what i suggest is that , at the time of dynamic memory allocation the memory would not been in the position to allocate that much of huge memory at a single instance...... UR MEMORY WILL BE INCAPABLE IF U TRY TO ALLOCATE A HUGE AMOUNT LIKE ABOVE FOR UR USE.......

u try this.... you declare an array size of 200 or 300... this will give a warning that MEMORY FULL........ the one of the disadvantages in C is that we cant balance a very large amount of data's which are outside the range .... so only we will go for DATA BASE.......



hope this helps u for getting some ideas.......

thank u

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

What is getch?

0 Answers  


What is the maximum no. of arguments that can be given in a command line in C.?

0 Answers   HCL,


what is the differance between pass by reference and pass by value.

7 Answers   Infosys,


How can I read in an object file and jump to locations in it?

0 Answers  


Write a program that takes a 5 digit number and calculates 2 power that number and prints it.

1 Answers  


Why shouldn’t I start variable names with underscores?

0 Answers  


What does c mean before a date?

0 Answers  


Write a program to find whether the given number is prime or not?

6 Answers  


What is the difference between procedural and functional programming?

0 Answers  


Why main is not a keyword in c?

0 Answers  


what is the importance of spanning tree?

0 Answers  


Is there a way to switch on strings?

0 Answers  


Categories