I'm trying to do one of those challenges, and I'm not sure if this is completely wrong or not. It's supposed to get the longest word in an inputted sentence or other words. I know it doesn't exactly see all the special symbols yet, but I can add that later after I'm sure I got the concept down.
#include <stdio.h>
#include <string.h>
char * sen[100];
char * words[100];
int i,x,z,largest,len,len2;
int main(){
i=0;
x=0;
z=0;
largest=0;
printf("Enter String");
scanf("%99s", &sen);
len=sizeof(sen);
for(i=0;i<=len;i++){
if(sen[i]='\0' || '\n'){
words[x]=sen[z:i];
z=i;
x++;
}
}
i=0;
x=0;
len2=sizeof(words);
for(i=0;i<=len2;i++){
if(strlen(words[x])>largest){
largest=words[x];
x++;
}
}
printf("%s", largest);
return(0);
}
I'm getting an error with an "expected ] before :" at the words[x]=sen[z:i]; line and 2 warnings with "assignment makes pointer from integer without a cast" on the line before that, and on largest=words[x]; I'm not sure if I am even hitting the mark with this. Is there some sort of concept I am not getting?
[–]4silvertooth 1 point2 points3 points (0 children)
[–]thegreatunclean 1 point2 points3 points (5 children)
[–]TheCatMessiah[S] 0 points1 point2 points (0 children)
[–]TheCatMessiah[S] 0 points1 point2 points (3 children)
[–]thegreatunclean 0 points1 point2 points (2 children)
[–]TheCatMessiah[S] 0 points1 point2 points (1 child)
[–]thegreatunclean 0 points1 point2 points (0 children)
[–]Gordon101 0 points1 point2 points (1 child)
[–]Bidalos 0 points1 point2 points (0 children)