17 - ICS 103 Computer Programming in C Handout 17 Topic Arrays of Strings Use of break and continue statements Objective To know what is arrays of

17 - ICS 103 Computer Programming in C Handout 17 Topic...

This preview shows page 1 - 2 out of 7 pages.

ICS 103: Computer Programming in C Handout-17 Topic: Arrays of Strings & Use of break and continue statements. Objective: To know what is arrays of strings and how to use it. ? To know use of break and continue statements. Arrays of strings: To represent arrays of strings we need two-dimensional arrays . The first- dimension represents the number of strings in the array and the second- dimension represents the length of each string. Example: #define LEN1 5 #define LEN2 81 char strarray [ LEN1 ] [ LEN2 ] = {“This”, “is”, “ICS103”, “Course”, “LAB”} ; char str [LEN2] = {“Instructor”} ; Here the array strarray is an array of 5 strings with the size of each string being 81. Thus strarray [0] [0] = ‘T’, strarray [0] [1] = ‘h’, strarray [0] [2] = ‘i’, strarray [0] [3] = ‘s’, strarray[0][4] = ‘\0’; Similarly, strarray [4] [0] = ‘L’, strarray [4] [1] = ‘A’, strarray [4] [2] = ‘B’, strarray[4][3] = ‘\0’. The string arrays can be read by using gets ( ) and printed by using puts ( ) inside a for loop as #include<stdio.h> #include<string.h> void main() { ICS 103 : Computer Programming in C , Term-012 ; Rafiq Khan Page 1 of 7
Image of page 1
Image of page 2

You've reached the end of your free preview.

Want to read all 7 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes