Everything is explained in the program on how it works. However, when compiled, it doesn't display the longest string. It displays the string I last entered. For example if I enter "What" "kind" "of" "program" "is" "this," it displays "this."
Code:#include <stdio.h> #include "strlib.h" #include "genlib.h" #include "simpio.h" main() { string i, z, g; printf ("This program displays the longest string out of the strings you input.\n"); printf ("Signal the end of your input list with the word 'end'.\n"); printf ("Enter your first string: "); g = GetLine(); while (!(StringEqual (g , "end"))) { z = g; printf ("Enter your next string: "); g = GetLine(); if (StringLength (g) > (StringLength (z))) { i = g; } } printf ("\nThe longest string is: %s", i); getchar(); }



2Likes
LinkBack URL
About LinkBacks



