@@ -16,44 +16,36 @@ void killClientBridge(char* message){
1616 exit (-1 );
1717}
1818
19-
2019char * * readFile (char * fileName ,int * numOfLines ){
21- FILE * input_file = fopen (fileName , "r" );
22- if (!input_file ){
20+ FILE * inputFile = fopen (fileName , "r" );
21+ if (!inputFile ){
2322 exit (EXIT_FAILURE );
2423 }
2524 int lines = 0 ;
26- numberOfLines (input_file , & lines );
27- printf ("cantidad lineas: %d\n" ,lines );
28- rewind (input_file );
25+ numberOfLines (inputFile , & lines );
26+ rewind (inputFile );
2927 char * * arrayChars = malloc (sizeof (char * ) * lines );
3028 char * contents = NULL ;
3129 size_t len = 0 ;
3230 int i = 0 ;
33- while (getline (& contents , & len , input_file ) != -1 ){
31+ while (getline (& contents , & len , inputFile ) != -1 ){
3432 int cm = stringLength (contents );
3533 char * newChars = (char * )malloc (cm );
3634 strcpy (newChars , contents );
3735 arrayChars [i ] = (char * )malloc (cm );
3836 arrayChars [i ] = newChars ;
39- // printf("%s\n", newChars);
4037 i ++ ;
41-
4238 }
43- // for (int i = 0; i < lines; i++)
44- // {
45- // printf("vector = %s\n",arrayChars[i]);
46- // }
47- fclose (input_file );
39+
40+ fclose (inputFile );
4841 free (contents );
4942 * numOfLines = lines ;
50- return arrayChars ;
43+ return arrayChars ;
5144}
5245
5346int stringLength (char * arrayChar ){
5447 int i = 0 ;
55- while (arrayChar [i ]!= '\0' )
56- {
48+ while (arrayChar [i ]!= '\0' ){
5749 i ++ ;
5850 }
5951 return i ;
@@ -67,10 +59,9 @@ int numberOfLines(FILE* file, int* size){
6759 if (character == '\n' ){
6860 i ++ ;
6961 }
70- if (character == EOF ){ //Si el caracter es end of file imprimimos el contador y salimos del while
62+ if (character == EOF ){
7163 i ++ ;
7264 * size = i ;
73- // printf("%d\n",i); //El número de lineas
7465 break ;
7566 }
7667 }
0 commit comments