Expand|Select|Wrap|Line Numbers
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <conio.h>
- #include <ctype.h>
- #include <ctype.h>
- #include <time.h>
- #include <sys/types.h>
- int main ( void )
- {
- static const char filename[] = "1.txt";
- FILE *file = fopen ( filename, "r" );
- int i, j;
- char arra[128][128];
- char line[128];
- int result;
- for(i=0; i<128; i++)
- for(j=0; j<128; j++)
- arra[i][j] = '\0';
- for(i=0; i<128; i++)
- line[i] = '\0';
- if ( file != NULL )
- {
- i=0;
- while ( fgets ( line, sizeof line, file ) != NULL )
- {
- strcpy(arra[i], line);
- printf("array ----> %s ", &arra[i]);
- i++;
- }
- fclose ( file );
- }
- else
- {
- perror ( filename );
- }
- return 0;
- }
this code is working nice
think if input file has text
shankar
ravi
kumar
kan
ravi
the output i will get has
array -> shankar
array ->ravi
array ->kumar
array ->kan
array ->ravi
c in the above output the name ravi has been repeated 2times .is that there is any possiblitly to remove the duplicate from the list above ....... and same way explain me how the values are stored in array .plz...........