Ok first off i have been trying to fix this problem the past several days and have looked up and read a ton of things and still cannot get this to work so DO NOT link me to another website at this point i just need someone to show me how to fix the part of my code that is wrong. I know what is wrong but whenever i try and fix it i get more errors so the best way for me to learn is seeing how the code looks when written correctly. Please do not comment on this if you are not going to help im sick of the useless comments and this program is due at midnight tonight so im already stressed and need this done. I never understood people when they said showing you the correct code wont help you learn because for me that is the best way to learn because i can look at the correct code and study it for future reference.Now that im done with that rant here is my code :
Code:
#include <stdio.h>
#include <string.h>
int main() {
char str[80+1];
int sentences, sWords, MWords, LWords, length, common;
sentences=sWords=MWords=LWords=length=common=0;
int capital=0;
char test[80+1];
printf("\nCSE 1030 Program Three - email - csp_03\n\n");
while(scanf("%s",str) != EOF) {
while(ispunct(strlen(str)-1))
{
if(str[strlen(str)-1] == '?' || str[strlen(str)-1] == '.' || str[strlen(str)-1] == '!')
{
sentences++;
}
str[strlen(str)-1] = '\0';
while(ispunct(str[0]))
{
strcat(str,str+1);
}
length = strlen(str) +1;
if(length < 6)
{
if ( length < 4 )
{
if(str == "the" || str == "The" || str == "a" || str == "A" || str == "of" || str == "Of" || str == "is" || str == "Is" || str== "that" || str=="That" || str == "are" || str=="Are")
{
common++;
sWords++;
}
else sWords++;
}
}
if(length >=6 && length < 12 ) MWords++;
if(length >= 12) LWords++;
strcpy(test,str);
test[0] = toupper(test[0]);
if(strcmp(test,str)==0) capital++;
}
}
printf("Summary of Results: \n\n");
printf("%d short length words\n",sWords);
printf("%d medium length words\n",MWords);
printf("%d long length words\n",LWords);
printf("%d capitalized words\n",capital);
printf("%d common words\n",common);
printf("%d sentences\n",sentences);
return 0;
}
Ok so what this prgram does is it takes a text file and says how many short,medium,long, etc.. words the paragraph has. So i know that i mseed up when i used the == sign for the string and believe i am supposed to use strcmp but whenever i try using strcmp i get a bunch of errors and get even more confused. Please show me the correct way to code that portion. Also, it is not printing out any of the printf statements at the end for some reason.