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
What kind of structure is a house?
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
Is c weakly typed?
write a programming in c to find the sum of all elements in an array through function.
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.
What is calloc()?
How to declare pointer variables?
Under what circumstances does a name clash occur?
Write a program to print fibonacci series using recursion?
Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;
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...
What is meant by inheritance?
Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
Explain what are multidimensional arrays?
Explain what are linked list?