0

Any one can to help my in the c languge

Questin is: scan string and get the first word in the string if the string have the first word print it example: This is my moment and this is awsome Print:this.

1st Jan 2020, 12:00 AM
Yosef Khier
Yosef Khier - avatar
8 Answers
+ 2
Use scanf to get input as a char array. Create a new char array, and, using a for loop, add every character that is not a space. Make the loop break when it reaches a space or end of line and make sure it is not added to the new char array.
1st Jan 2020, 12:23 AM
Fernando Pozzetti
Fernando Pozzetti - avatar
+ 5
Sorry but the question is hard to understand.
1st Jan 2020, 4:20 PM
Sonic
Sonic - avatar
+ 3
The scanf() method stops reading the input as soon as it encounters a space character so make use of the fgets() to take user input and you can make use of a pointer and run a for loop to get your result easily.
1st Jan 2020, 1:26 AM
Avinesh
Avinesh - avatar
+ 3
Sonic he is trying to read a string input like a sentence and just wants to print the first word from that string.
1st Jan 2020, 4:27 PM
Avinesh
Avinesh - avatar
+ 2
Why do you need to complicate it? This is one way. https://code.sololearn.com/cJypyV9cc9qv/?ref=app
1st Jan 2020, 9:41 AM
Avinesh
Avinesh - avatar
0
https://code.sololearn.com/cKX0aYGxbWOg/?ref=app
1st Jan 2020, 9:12 AM
Yosef Khier
Yosef Khier - avatar
1st Jan 2020, 9:12 AM
Yosef Khier
Yosef Khier - avatar
0
Avinesh thanks
1st Jan 2020, 7:27 PM
Yosef Khier
Yosef Khier - avatar