Home / C Programming / Strings :: Discussion

Discussion :: Strings

  1. What will be the output of the program ?

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

  2. A.

    Error

    B.

    FresherGATE

    C.

    Base address of str

    D.

    No output

    View Answer

    Workspace

    Answer : Option A

    Explanation :

    The line char str = "FresherGATE"; generates "Non portable pointer conversion" error.

    To eliminate the error, we have to change the above line to

    char *str = "FresherGATE"; (or) char str[] = "FresherGATE";

    Then it prints "FresherGATE".


Be The First To Comment