Category : C Source Code
Archive   : C-TOOLBX.ZIP
Filename : REVERSE.C

 
Output of file : REVERSE.C contained in archive : C-TOOLBX.ZIP
/* reverse.c - checks a phrase to see if it is a palindrome */
#include "stdio.h"

main()
{
char phrase[81] ;
char rev_phrase[81] ;

printf("Type a phrase : \n");/* prompt for phrase from keyboard */
getstr(phrase,80) ; /* and get it */

do_reverse(phrase,rev_phrase) ; /* construct reversed phrase */
if( strcmp(phrase,rev_phrase) == 0 ) /* compare original */
printf(" ** PALINDROME ** ");
else printf(" REVERSE = %s",rev_phrase) ;
}

int do_reverse(s1,s2) /* reverse a string */
char s1[] ; /* the string to be reversed */
char s2[] ; /* place its reverse here */
{
int i , j ;
/*copy characters starting at end of s1 */
i = 0 ;
j = strlen(s1) - 1 ; /* find index of last character in s1 */
while( j >= 0 )
{ s2[i] = s1[j] ;
i = i + 1 ;
j = j - 1 ;
}
s2[i] = 0 ; /* mark end of string */
}




  3 Responses to “Category : C Source Code
Archive   : C-TOOLBX.ZIP
Filename : REVERSE.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/