{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Homework7-2 - Homework#7 Program HW7_2 Written by Justin...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Homework #7 /* * Program : HW7_2 * Written by Justin Waters * Inputs: 2 words * Outputs: common prefix of the 2 words * Description: User enters 2 words and the program finds the longest common prefix shared by both words * */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> //prototypes int prefixer(char word1[], char word2[]); //function for comparing words void explain(void); //function to tell user about the program int main (void) { char word1[40], word2[40]; int replay; explain(); //calls function to tell user about the program //loop for repeated comparisons do { printf("\n\nEnter a word\n\n"); //gets users 1st word fflush(stdin); scanf("%s",word1); printf("\n\nEnter another word\n\n"); //gets users 2nd word fflush(stdin); scanf("%s",word2); prefixer(word1,word2); //sends 2 words to comparing function //asks if user wants to do it again printf("\n\nDo you want to try it again?"); printf("\n\nPress '1' to do it again, or '0' to quit\n\n"); scanf("%d", &replay); }while(replay == 1);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
//prints after user wants to quit printf("\n\nThanks for using my program!\n"); return(0); }
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}