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....

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What kind of structure is a house?

562


a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f

1593


Is c weakly typed?

583


write a programming in c to find the sum of all elements in an array through function.

1712


1.int a=10; 2.int b=20; 3. //write here 4.b=30; Write code at line 3 so that when the value of b is changed variable a should automatically change with same value as b. 5.

1670






What is calloc()?

633


How to declare pointer variables?

690


Under what circumstances does a name clash occur?

700


Write a program to print fibonacci series using recursion?

593


Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;

619


I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...

9663


What is meant by inheritance?

639


Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

680


Explain what are multidimensional arrays?

609


Explain what are linked list?

628