Warning for dynamic memory allocation Programming Software Development by Zach101man …quot;, SIZE, SIZE); /*******Making Array dynamically**************/ matrix = alocate(SIZE); tmpmat = alocate(SIZE); C = alocate(SIZE); /************End of dyanamic array making********/ [/code] …]makes integer from pointer without a cast [code=C] int alocate(int SIZE) { int i; int **new; new = malloc(… Read file with unknown buffer length Programming Software Development by xibnoe … in one variabel. i am confuse how much i should alocate the buffer size? [code] #include <stdio.h> int… main() { char buf[255]; <<HOW MUCH SHOULD WE ALOCATE TE BUFFER? FILE* fp = fopen("somefile.txt","… Re: Read file with unknown buffer length Programming Software Development by Ancient Dragon … lines char buf[255]; <<HOW MUCH SHOULD WE ALOCATE TE BUFFER? FILE* fp = fopen("somefile.txt","… Re: Read file with unknown buffer length Programming Software Development by WaltP … in one variabel. i am confuse how much i should alocate the buffer size?[/quote] Unless you know how many characters… More problems with pointers and functions Programming Software Development by Yellowdog428 … would you like to enter? "; cin >> arraySize; //alocate memory array = new int[arraySize]; //collect data for (count = 0… How can I pass the vaues of array to struct array? Programming Software Development by fishwater00 …; [/code] VELOCITY in struct MODEL is also float. then I alocate memory for them; [code=c] velocity = malloc( NX*NY*NZ… Memory Allocation...where? when? how? Programming Software Development by soudruhcz … good but I don't know where I have to alocate memory. And for which structures or something else I have… new/free() or mallco/delete Programming Software Development by angelinrajeesha Hi, Is it possible to allocate memory using malloc() (C) and release it using delete (C++) or even the opposite Alocate with new (C++) and release with free() (C) If not Why? Recover deleted drive partition.. help! Hardware and Software by fuzebox40 … HDD as my storage. Ok, so I tried to re-alocate the space, but I did something back-asswards and deleted… Re: Shift Booking System Programming Software Development by Ionelul …, so it would be enough for every shift introduced to alocate the EventId key case 2: shifts are pre-defined and… Re: Array problem Programming Software Development by Majestics In java u have to dynamically alocate resources for array... for Line 3 you need a = new int[size of array]; Re: vector and array Programming Software Development by nitin1 that means having memory from heap is better than having memory from stack ? but i have felt that malloc function usually takes longer time so as to alocate memory. (malloc also do dynamic allocation). then ? Re: vector and array Programming Software Development by ravenous … that malloc function usually takes longer time so as to alocate memory. It does take slightly longer, but is that time… Re: malloc and free implementation Programming Software Development by ms95 im sorry i've forgotten to add the testcases and alocate function . i've added them above . thanks Re: Warning for dynamic memory allocation Programming Software Development by jephthah you're trying to return an [ICODE]int **[/ICODE], and your assignments expect the same. but your function return type is [ICODE]int[/ICODE] Re: Warning for dynamic memory allocation Programming Software Development by Zach101man Thanks that works, I knew it had to be something simple. I'm still trying to get used to these pointers Re: Read file with unknown buffer length Programming Software Development by John A Well, since you're only reading in one line of the file at a time, you should have some idea of how long the lines will be. Choose a buffer size that is large enough to hold these requirements. Since we don't know what files you're planning to read, we can't give a perfect guess. This question is similar to "how large should I make this field… Re: More problems with pointers and functions Programming Software Development by vmanes In main( ), you have a value lowest and a pointer to it, lowptr. Your function dropLowest( ) takes a parameter by value, to which you store the lowest found value, and return that. Back in main( ), you do not capture that returned value, so it's lost (the dropped bits are what make the dust bunnies you find in your computer.) Why not simply … Re: More problems with pointers and functions Programming Software Development by Yellowdog428 Thanks! Sometimes it is the easiest things... Cheers! Re: How can I pass the vaues of array to struct array? Programming Software Development by jephthah where is "MODEL" defined? Re: How can I pass the vaues of array to struct array? Programming Software Development by fishwater00 [QUOTE=jephthah;637820]where is "MODEL" defined?[/QUOTE] "MODEL" is defined in .h file, and every .c file includes this .h file. I didnot type in it because I think it is not the point. Am i right? Re: How can I pass the vaues of array to struct array? Programming Software Development by ssharish2005 hmm this is the first time i am looking at a different way of allocating a 3D array. But referecing the elements within that is something really interesting. This is how i use to follow [code=C] #include <stdio.h> #include <stdlib.h> int main() { int ***array; int i, j; if( ( array = malloc( sizeof( int **)… Re: How can I pass the vaues of array to struct array? Programming Software Development by jephthah never mind. Re: Memory Allocation...where? when? how? Programming Software Development by Stinomus You need to allocate memory - using the 'new' operator - for anything you want to reside on the heap (as opposed to the stack) and the rule is that if you 'new' it, then when you are finished with it you must 'delete' it. It is also good practise to set the pointer to 0 when you have called 'delete' on it (that is, de-allocated the memory it points… Re: Memory Allocation...where? when? how? Programming Software Development by MosaicFuneral You only need memory allocation when you need memory for n-objects... Re: Memory Allocation...where? when? how? Programming Software Development by Stinomus [QUOTE=MosaicFuneral;873314]You only need memory allocation when you need memory for n-objects...[/QUOTE] Not only that, stack space is limited so creation of large data structures is generally more suited to the heap. Re: Memory Allocation...where? when? how? Programming Software Development by soudruhcz So map and queue are OK, but I have to allocate memory for structures Elevator and Person? But I haven't got them as pointer and "void * malloc ( size_t size );" I don't know how use it in my programm. Re: new/free() or mallco/delete Programming Software Development by Aranarth You can't, because new can work very differently from malloc and have its own memory management scheme. You can only pass pointers that were returned by malloc to free - those returned by new probably were never returned by malloc. Interchanging free/delete and new/malloc might seem to work in some cases, namely when new and delete are … Re: new/free() or mallco/delete Programming Software Development by mrnutty @OP: There is simply no reason to do this. Why would you want to do this? Re: Recover deleted drive partition.. help! Hardware and Software by Brittany_3 I had the same problem. Can you help me. Thanks