• +91 9723535972
  • info@interviewmaterial.com

CPlusPlus Interview Questions and Answers

Question - Write a fucntion that will reverse a string.

Answer - char *strrev(char *s) { int i = 0, len = strlen(s); char *str; if ((str = (char *)malloc(len+1)) == NULL) /*cannot allocate memory */ err_num = 2; return (str); } while(len) str[i++]=s[–len]; str[i] = NULL; return (str); }

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners