Skip to content

Commit 6261414

Browse files
author
tmikolov
committed
removed gets() function
1 parent c29418e commit 6261414

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

distance.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,15 @@ int main(int argc, char **argv) {
6262
for (a = 0; a < N; a++) bestd[a] = 0;
6363
for (a = 0; a < N; a++) bestw[a][0] = 0;
6464
printf("Enter word or sentence (EXIT to break): ");
65-
gets(st1);
65+
a = 0;
66+
while (1) {
67+
st1[a] = fgetc(stdin);
68+
if ((st1[a] == '\n') || (a >= max_size - 1)) {
69+
st1[a] = 0;
70+
break;
71+
}
72+
a++;
73+
}
6674
if (!strcmp(st1, "EXIT")) break;
6775
cn = 0;
6876
b = 0;
@@ -124,4 +132,4 @@ int main(int argc, char **argv) {
124132
for (a = 0; a < N; a++) printf("%50s\t\t%f\n", bestw[a], bestd[a]);
125133
}
126134
return 0;
127-
}
135+
}

0 commit comments

Comments
 (0)