By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,389 Members | 1,881 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,389 IT Pros & Developers. It's quick & easy.

help in C

P: 1
how to change an array index with a MAX=1000 to a pointer that can hold unlimited char
Sep 27 '06 #1
Share this Question
Share on Google+
1 Reply


Banfa
Expert Mod 5K+
P: 8,916
Using type int for illustration, instead of

Expand|Select|Wrap|Line Numbers
  1. #define MAX 1000
  2.  
  3. int array[MAX];
  4.  
use

Expand|Select|Wrap|Line Numbers
  1. int *pointer;
  2. int arraySize = 1000;  // Note I have used 1000 but this is not fixed
  3.  
  4. pointer = malloc(sizeof *pointer * arraySize);
  5.  
Sep 27 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.