summaryrefslogtreecommitdiffstats
path: root/4
diff options
context:
space:
mode:
authorSadeep Madurange <smadurange@users.noreply.github.com>2021-12-29 19:57:23 +0800
committerSadeep Madurange <smadurange@users.noreply.github.com>2021-12-29 19:57:23 +0800
commit807b4e70b1a286ac7fe1f28517c05805f428089c (patch)
treed4ea4dd492b5da801379325269bfc8c5e3e95e8b /4
parente7242d30471a02d648846c3a63226315126748fc (diff)
downloadk&r-exercises-807b4e70b1a286ac7fe1f28517c05805f428089c.tar.gz
4.13
Diffstat (limited to '4')
-rw-r--r--4/13.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/4/13.c b/4/13.c
index cc359aa..28918c5 100644
--- a/4/13.c
+++ b/4/13.c
@@ -11,10 +11,9 @@ int main(int argc, char *argv[]) {
char *s;
size_t n;
- s = malloc(MAXLEN);
- n = sizeof(s);
+ s = malloc(sizeof(char) * MAXLEN);
- getline(&s, &n, stdin);
+ fgets(s, MAXLEN, stdin);
reverse(s, 0, strlen(s) - 2);
printf("\t%s\n", s);