answersLogoWhite

0

Subscripts are used when accessing arrays. An array is a contiguous block of memory containing two or more elements of the same type. Since each element is the same length, it is trivial to work out the offset address of one element relative to another using a zero-based index. For any type T, the type T[n] is an array of Ts with indices in the range 0 to n-1. We can also create arrays at runtime by allocating sufficient memory on the heap for the given type:

void f(int n) {

if (n<1) return; // cannot allocate 0 elements!

int* ptr = malloc (n * sizeof(int)); // allocate memory for n integers

if (ptr!=0) return; // ensure memory was allocated!

ptr[0] = 42; // use subscript operator to assign a value to the first element

// assign to other elements...

// use array...

free (ptr); // release memory as soon as we're finished with it

}

User Avatar

Wiki User

9y ago

What else can I help you with?

Related Questions

Explain specifically what the subscripts mean in the molecule formula C6H12O6?

explain specifically what the subscripts mean in the molecule formula c 6 h 12 o 6


Do any languages have array subscripts beginning with 1?

Yes, PHP and C both do.


What is the total number of atoms of carbon in the formula K3FeCN6?

In chemical formulas, carbon atoms are denoted with the symbol C. Subscripts and superscripts denote the number of carbons. Since there is only one C and no subscripts or superscripts, the compound stated contains only one carbon atom.


Why c language has name c why not a?

C-language was derived from B-language.


What is previous language of c language?

language before c language is pascal


What is C language what does it do?

C Language is First Step of Programming Language, Help for C Language you are show the correct answer


Array subscripts are always a large numbers b characters c negative values d integers?

d integers


What is versions of c language?

versions of c language?


Is c a dependent language?

C is a independent language


What do you mean by c language?

C is a programming language.


What is the topNet class that everything is derived from in c?

C language: int (but C is NOT a .net language) C# language: object or System.Object


What is the program language c?

C is a pop language. C is a case sensetive language. C is motherof all language. C is block structure language. C is a high level language. C is advace of B language. C developed by D.richties in 1972 at AT &amp; T Bell lab in USA. Sachin Bhardwaj 986854722 skbmca@gmail.com