I am still having trouble with the function getline and was hoping some of you guys could help me fix my program. The goal is to read a sentence typed in by the user (instead of ending with a period it ends with the word "end") and then print out the largest word and how long it was.
#include "stdio.h"
#include "string.h"
int main(){
string input;
int length;
int Maxlength;
int MaxStr;
printf ("What do you want your sentence to be? ");
scanf ("%s")
length = strlen(input);
while (!stringEqual(input,"end"))
{
input = getline();
length = strlen(input);
if (length > Maxlength)
{
Maxlength = length;
MaxStr = input;
}
}
printf ("The longest string was %s with %d characters", MaxStr, Maxlength);
return 0;
}
I am using C and I know that this a C++ forum but I was hoping you guys could overlook that and help with the problem. Thanks for your trouble!