File tree Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change 99#include "../player/main.h"
1010
1111unsigned char requestPlayerNames (SList * players ) {
12- char * lineBreak ;
13-
1412 Player player ;
1513 char playerName [PLAYER_NAME_LENGTH ];
1614
@@ -19,10 +17,9 @@ unsigned char requestPlayerNames(SList *players) {
1917 fgets (playerName , PLAYER_NAME_LENGTH , stdin );
2018 puts ("" );
2119
22- lineBreak = strrchr (playerName , '\n' );
23- if (lineBreak != NULL ) * lineBreak = '\0' ;
20+ trimString (playerName );
2421
25- if (* playerName == '0' ) return 0 ;
22+ if (strlen ( playerName ) == 0 || * playerName == '0' ) return 0 ;
2623
2724 newPlayer (& player , playerName );
2825
@@ -34,10 +31,9 @@ unsigned char requestPlayerNames(SList *players) {
3431 fgets (playerName , PLAYER_NAME_LENGTH , stdin );
3532 puts ("" );
3633
37- lineBreak = strrchr (playerName , '\n' );
38- if (lineBreak != NULL ) * lineBreak = '\0' ;
34+ trimString (playerName );
3935
40- if (* playerName == '0' ) break ;
36+ if (strlen ( playerName ) == 0 || * playerName == '0' ) break ;
4137
4238 newPlayer (& player , playerName );
4339
You can’t perform that action at this time.
0 commit comments