The problem of the realization of Krypr exercise 5-13 tail [- n]

1. Environment:

centOS 7 virtual machine

2. Code:

tag: tail.c

-sharpinclude<stdio.h>

int my_getline(char *s, int maxlens)
{   
    int c;
    int i;
    for(i = 0; i < maxlens && (c=getchar())!= EOF && c != "\n"; iPP)
        *sPP = c;
    if(c == "\n")
    {
        *sPP = "\n";
        iPP;
    }
    *sPP = "\0";
    return i;
}

3. Question:

compilation will pass, but will occur during execution:
first case:

[root@server0 tail]-sharp ./tail -4
Segmentation fault (core dumped)
[root@server0 tail]-sharp ls

Segmentation fault (core dumped) is output after pressing ctrl + d (EOF)
the second case:

[root@server0 tail]-sharp ./tail
fjgdshafgk
dhfdsjhfj
jfhds
dfhd
jdfh
jfdf
sadfjsasjf
adjfsadfjaskdjfk
njdfnjsda
jjdanfj
jfhdsjfhsasjdsj
1
54[
5;5
55
88"
66
99
66

644
555
66
Segmentation fault (core dumped)
[root@server0 tail]-sharp ls

(tail is an executable program generated after compilation)

could you tell me what"s wrong with this program?

C
May.22,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb1353-2339.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb1353-2339.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?