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
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 |
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 |
How are portions of a program disabled in demo versions?
void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }
main() { int x=5,y=10,z=0; x=x++ + y++; y=y++ + ++x; z=x++ + ++y; printf("%d%d%d\n",x,y,z); }
write a program to print the one dimensional array.
main() { int i,j,A; for(A=-1;A<=1;A++) prinf("%d\t",!!A); }
though sbi was nationalized why its not comes under nationalized banks and its comes under publicsector banks
3 Answers State Bank Of India SBI,
Snake Game: This is normal snake game which you can find in most of the mobiles. You can develop it in Java, C/C++, C# or what ever language you know.
7 Answers Accenture, Gridco, IBM, Kevin IT, TCS, Vimukti Technologies,
Can u return two values using return keyword? If yes, how? If no, why?
What is the Difference between Macro and ordinary definition?
3 Answers Bosch, Cognizant, College School Exams Tests, Motorola,
In C, What is the #line used for?
What is the output of printf("%d", printf("Hello"));?
if p is a string contained in a string?