List of Strings
• Real-Time applications often require storage and
manipulation of a number of strings (i.e. List of strings)
and not only a single string.
• A list of strings can be stored on two ways:
1. Using an array of strings
2. Using an array of character pointer
Array of Strings:
• If an application requires the storage of multiple strings,
an array of strings can be used to store them.
• The list of strings can be stored by creating an array of one
dimensional character arrays (i.e. Two-dimensional
character array)
Declaration of Array of strings
Syntax:
Char String_name[Row_size][column_size]={ values};
• Array of strings declaration consists of char type specifier,
an identifier name, row size specifier and column size
specifier.
char str1[2][30];  Str1 can store 2 strings of
maximum 30 characters each
char str2[5][10];  str2 can store 5 strings of
maximum 10 characters each
Declaration of Array of strings
• Initialization of array of strings: Array of strings can be
initialized in two ways:
a. Using String literal constants:
b. Using a list of character initializers:
Array of Character Pointers
• An array of strings can also be stored by using an array of
character pointers.
• The starting addresses of strings are stored in an array of
character pointers.
Command Line Arguments
• The inputs are given at the command line or command prompt
are known Command Line Arguments.
• To retrieve the command line arguments, the function main
should be defined as:
main(int argc, char *argv[])
{
……. // Body of main function
…….
}
• In the header of the main function, two parameters are given,
namely:
• argc Argument Count and is of integer type
• argv Argument Value ia an array of character pointers.

SPC Unit 4

  • 1.
    List of Strings •Real-Time applications often require storage and manipulation of a number of strings (i.e. List of strings) and not only a single string. • A list of strings can be stored on two ways: 1. Using an array of strings 2. Using an array of character pointer Array of Strings: • If an application requires the storage of multiple strings, an array of strings can be used to store them. • The list of strings can be stored by creating an array of one dimensional character arrays (i.e. Two-dimensional character array)
  • 2.
    Declaration of Arrayof strings Syntax: Char String_name[Row_size][column_size]={ values}; • Array of strings declaration consists of char type specifier, an identifier name, row size specifier and column size specifier. char str1[2][30];  Str1 can store 2 strings of maximum 30 characters each char str2[5][10];  str2 can store 5 strings of maximum 10 characters each
  • 3.
    Declaration of Arrayof strings • Initialization of array of strings: Array of strings can be initialized in two ways: a. Using String literal constants: b. Using a list of character initializers:
  • 4.
    Array of CharacterPointers • An array of strings can also be stored by using an array of character pointers. • The starting addresses of strings are stored in an array of character pointers.
  • 5.
    Command Line Arguments •The inputs are given at the command line or command prompt are known Command Line Arguments. • To retrieve the command line arguments, the function main should be defined as: main(int argc, char *argv[]) { ……. // Body of main function ……. } • In the header of the main function, two parameters are given, namely: • argc Argument Count and is of integer type • argv Argument Value ia an array of character pointers.