#include #include #include #define LINES 10 int main() { int bytes_read, q; int nbytes = 100; char *my_string = NULL; char arrstr[LINES][100]; FILE *infile; char t; int fi; float ff; infile = fopen("testtext.txt", "r"); puts ("Reading data from testtext.txt\n"); /* These 2 lines are the heart of the program. */ my_string = (char *) malloc (nbytes + 1); for (q = 0; q < LINES; q++) { fscanf(infile,"%d %f",&fi, &ff); fgetc(infile); bytes_read = getline (&my_string, &nbytes, infile); strcpy(arrstr[q],my_string); if (bytes_read == -1) { puts ("ERROR!"); } else { puts ("You typed:"); puts (my_string); puts(arrstr[q]); printf("Numbers are : %d %f",fi, ff); // printf("\nthe fourth char is %c and %c\n", *(my_string+3),arrstr[q][3]); // printf("\nthe fifth char is %c and %c\n", my_string[4],*((arrstr + q ) + 4 ) ); } } return 0; }