Breaking

शनिवार, 4 अप्रैल 2020

BCA 2nd Sem Notes -Declaration and Initialization of strings

  • UNIT-I (Array)
Definition
Declaration & initialization of 1D 
Accessing array elements
Displaying array elements
Sorting arrays
Arrays and function
Declaration & initialization of 1D
Accessing and Displaying
Memory representation of array [Row Major, Column Major]
Multidimensional array



  • UNIT-II (Pointers)
  • Definition

    Declaration & initialization
    Indirection operator
    address of operator
    pointer arithmetic
    dynamic memory allocation
    arrays and pointers
    function and pointers




  • UNIT-III (Strings)

  •   strlen(),strcpy(),       strcat() ,strcmp()



  • UNIT-IV (Structures)
  • Definition



  • UNIT-V                                     (C Pre-processor)




  • UNIT-VI                                (File Handling)


  • Definition of Files,
    Opening modes of files
    Standard function
    fopen(), fclose(),             feof()  fseek(),                    fewind()
    Using text files
    fgetc(), fputc(), fscanf()

    Declaration and Initialization of strings

    Declaring an array of strings this way is rather tedious, that’s why C provides an alternative syntax to achieve the same thing. This above initialization is equivalent to:
    har ch_arr[3][10] = {
                             "spike",
                             "tom",
                             "jerry"
                         };
    The first subscript of the array i.e 3 denotes the number of strings in the array and the second subscript denotes the maximum length of the string. Recall the that in C, each character occupies 1 byte of data, so when the compiler sees the above statement it allocates 30 bytes (3*10) of memory.
    the initialization of a string variable,

    Char first_name[15]="ARYAN";
    Char first_name[15]={'A','R','Y','A','N','\0'};//null character '\0' is required at end in declaration
    char string1[6]="hello"; /* string size ='h'+'e'+'l'+'l'+'o'+'\0'=6*/*
     Previous Page                                          Print Page
    Next Page  

    कोई टिप्पणी नहीं:

    एक टिप्पणी भेजें