Home / C Programming / Strings :: Discussion

Discussion :: Strings

  1. What will be the output of the program ?

    #include 
     int main() 
     {   
        char str[7] = "FresherGATE";     
        printf("%s\n", str);   
        return 0; 
     } 
    

  2. A.

    Error

    B.

    FresherGATE

    C.

    Cannot predict

    D.

    None of above

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    Here str[] has declared as 7 character array and into a 8 character is stored. This will result in overwriting of the byte beyond 7 byte reserved for '\0'.


Be The First To Comment