Homework7-2 - Homework #7 /* * Program : HW7_2 * Written by...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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); //prints after user wants to quit...
View Full Document

This note was uploaded on 08/06/2008 for the course EGR 261 taught by Professor Parikh during the Spring '08 term at Grand Valley State University.

Page1 / 4

Homework7-2 - Homework #7 /* * Program : HW7_2 * Written by...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online