# Lec26-CS110 Computational Engineering

67 %
33 %
Education

Published on March 3, 2014

Author: SriHarsha1508

Source: slideshare.net

## Description

A keynote on Problem Solving using Computers

Pointers V. Kamakoti

Pointers and Multidimensional Arrays • A two dimensional array is a collection of CONTIGUOUS one dimensional arrays. • int x[10][20] - can be written as – int (*x)[20]; – “x” points to the first element of the first 20 element array - first (zeroth) row – “x+1” points to the first element of the second 20 elements array - One’th row. – Interestingly - x[2][5] is equivalent to *(*(x+2) + 5)

Contiguous Arrays continued • • • • • a[row][col] == *(*(a+row) + col) scanf (“%d”,&a[row][col]); scanf(“%d”,(*(a+row)+col)); printf (“%d”,a[row][col]); printf(“%d”,*(*(a+row)+col));

Strings and Pointers • char *name - is a string • char *names[] - is an array of strings • char names[10][12] – Array of 10 strings, each 12 characters in length. • char *names[10]; – names[0], ….., names[9] are all pointers – So array of pointers

Strings and Pointers • If we want an array of “10” strings each of maximum size “n” characters • char *names[10]; – – – – names[0], ….., names[9] are all pointers So array of pointers Different from 2-dimensional arrays 2-dimensional arrays are CONTIGUOUS one dimensional arrays • Array of strings NEED NOT BE CONTIGUOUS ONE DIMENSIONAL Arrays

Objective • Understand difference between 2-D arrays and Array of Pointers. • Declaration • int x[10][20]; int (*x)[20] • char mystr[10][20]; char *mystr[10] • What is char (*mystr)[20] - a two dimensional array of characters

 User name: Comment:

## Related presentations

#### PSYCH 640 RANK Change The World /psych640rank.com

September 26, 2017

#### SEC 440 OUTLET Change The World /sec440outlet.com

September 26, 2017

#### Philip Young MD - Anesthesia Options At Our Seattl...

September 26, 2017

#### English Tuition Centre - Tuition Classes

September 26, 2017

#### The Most Advanced Digital Marketing Course Learn A...

September 26, 2017

#### Ethical Hacking Training in noida

September 26, 2017

## Related pages

### Lec14-CS110 Computational Engineering - Education

International Journal of Computational Engineering Research(IJCER) ... Lec26-CS110 Computational Engineering. Lec19-CS110 Computational Engineering.