Home / C Programming / Strings :: Discussion

Discussion :: Strings

  1. What will be the output of the program (Turbo C in 16 bit platform DOS) ?

    
     #include
     #include 
    
      int main() 
      {    
          char *str1 = "Fresher";    
          char *str2 = "GATE";     
          char *str3;    
          str3 = strcat(str1, str2);     
          printf("%s %s\n", str3, str1);    
          return 0;
      } 
    

  2. A.

    FresherGATE Fresher

    B.

    FresherGATE FresherGATE

    C.

    Fresher Fresher

    D.

    Error

    View Answer

    Workspace

    Answer : Option B

    Explanation :

    It prints 'FresherGATE FresherGATE' in TurboC (in 16 bit platform).

    It may cause a 'segmentation fault error' in GCC (32 bit platform).


Be The First To Comment