52 lines
1007 B
C
52 lines
1007 B
C
|
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
//int main(void)
|
||
|
//{
|
||
|
// FILE * fp;
|
||
|
// char * line = NULL;
|
||
|
// size_t len = 0;
|
||
|
// ssize_t read;
|
||
|
//
|
||
|
// fp = fopen("/etc/fstab", "r");
|
||
|
// if (fp == NULL)
|
||
|
// exit(EXIT_FAILURE);
|
||
|
//
|
||
|
// while ((read = getline(&line, &len, fp)) != -1) {
|
||
|
// printf("Retrieved line of length %zu:\n", read);
|
||
|
// printf("%s", line);
|
||
|
// }
|
||
|
//
|
||
|
// fclose(fp);
|
||
|
// if (line)
|
||
|
// free(line);
|
||
|
// exit(EXIT_SUCCESS);
|
||
|
//}
|
||
|
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#define MAX_LINE_LENGTH 1000
|
||
|
|
||
|
int main() {
|
||
|
int num;
|
||
|
FILE *fptr;
|
||
|
char line[MAX_LINE_LENGTH];
|
||
|
|
||
|
fptr = fopen("../gene.txt", "r");
|
||
|
|
||
|
if (fptr == NULL) {
|
||
|
printf("File is empty!");
|
||
|
exit(1);
|
||
|
}
|
||
|
|
||
|
while (fgets(line, MAX_LINE_LENGTH, fptr)!=NULL) {
|
||
|
printf("%s", line);
|
||
|
|
||
|
char gene[MAX_LINE_LENGTH];
|
||
|
double weight;
|
||
|
sscanf(line,"%s %f", gene, &weight);
|
||
|
|
||
|
printf("\nGene: %s has weight %lf\n", gene, weight);
|
||
|
}
|
||
|
}
|