Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How can I dynamically allocate arrays?
How can I dynamically allocate arrays?
✍: Guest
The equivalence between arrays and pointers allows a pointer to malloc'ed memory to simulate an array quite effectively. After executing
#include <stdlib.h>
int *dynarray;
dynarray = malloc(10 * sizeof(int));
(and if the call to malloc succeeds), you can reference dynarray[i] (for i from 0 to 9) almost as if dynarray were a conventional, statically-allocated array (int a[10]). The only difference is that sizeof will not give the size of the ``array''
2016-04-23, 2710👍, 0💬
Popular Posts:
How To Use "IN OUT" Parameter Properly? - Oracle DBA FAQ - Creating Your Own PL/SQL Procedures and F...
Regarding C Coding Given: Line in file Contents 30 int * someIDs, theFirst, *r; 110 someIDs =GetSome...
What are secure and non-secure websites? A secure Website uses the Secure Socket Layer (SSL) protoco...
How To Create an Add-to-Netvibes Button on Your Website? - RSS FAQs - Adding Your Feeds to RSS News ...
How To Compare Two Strings with strcmp()? - PHP Script Tips - PHP Built-in Functions for Strings PHP...