Why am i not getting correct output please help | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Why am i not getting correct output please help

The program is to print largest word from string https://code.sololearn.com/cj0lBTU1x6ZF/?ref=app

12th Sep 2020, 9:34 AM
Prashant Pandey
Prashant Pandey - avatar
8 ответов
+ 1
Answer please
12th Sep 2020, 10:53 AM
Prashant Pandey
Prashant Pandey - avatar
+ 1
One of your error is on the 14th line. You need to increase the variable i inside the while loop.
12th Sep 2020, 11:47 AM
Nurullah Aydın
Nurullah Aydın - avatar
0
Do you have to implement this manually? I can suggest you to use `strtok` function for this. But if you were to make your own implementation, then it's a no good idea.
12th Sep 2020, 10:57 AM
Ipang
0
Can you please send a full solution
12th Sep 2020, 11:50 AM
Prashant Pandey
Prashant Pandey - avatar
0
#include<stdio.h> #include<conio.h> #include<string.h> main() { char a[50],b[20],c[20]; int i,j=0,l=0; printf("Enter a string:\n"); gets(a); for(i=0;i<=strlen(a);i++) { if(a[i]!=32 && a[i]!='\0') b[j++]=a[i]; else { b[j]='\0'; if(strlen(b)>l) { strcpy(c,b); l=strlen(b); } j=0; } } printf("The longest word is:"); puts(c); getch(); }
12th Sep 2020, 11:55 AM
Nurullah Aydın
Nurullah Aydın - avatar
0
Thankyou so much
12th Sep 2020, 11:56 AM
Prashant Pandey
Prashant Pandey - avatar
0
You can examine this code and ask me what you dont understands.
12th Sep 2020, 11:57 AM
Nurullah Aydın
Nurullah Aydın - avatar
0
Ok
12th Sep 2020, 11:58 AM
Prashant Pandey
Prashant Pandey - avatar