[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

array size

how to increse the array size dynamically and statically
0
prasad2315
Asked:
prasad2315
1 Solution
 
SolutionsCSCommented:
Here is your answer
    http://www.source-code.biz/snippets/csharp/1.htm

Here is a litle tutorial on using array's
    http://msdn2.microsoft.com/en-us/library/aa288453(VS.71).aspx
0
 
prasad2315Author Commented:
how to increase the array size dynalically  and statically in c language
0
 
Infinity08Commented:
If by array, you mean a static array :

        int array[20];

then you can't increase its size.

For dynamic arrays, you can use realloc :

        int *array = (int*) calloc(20, sizeof(int));
        int *tmp = (int*) realloc(array, 40 * sizeof(int));
        if (!tmp) {
            /* error : memory increase failed !! */
        }
        else {
            array = tmp;
        }

Reference page for realloc :

        http://www.cplusplus.com/reference/clibrary/cstdlib/realloc.html
0

Featured Post

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now