The effects you are seeing are typical for buffer overflows.
You have two arrays with fixed sizes that are accessed without bound checking:
temp
used in Line_Address()
is accessed by the variable i
. If i
is greater or equal to 70, you will have a buffer overflow.keystroke[10]
in main()
is accessed up to the index Delimers
- 1. There will be a buffer overflow if Delimers
is greater than 10.
To fix these, you must add code that checks the indexes and terminates the loops if the limits are reached.
You are calling
strlen(temp)
without terminating
temp
. You initially terminated it, but this will be overwritten when
i
becomes 69. Even when
i
is less than 69, you are processing garbage because
strlen()
may return any value between the number of assigned chars and 69. To fix this, add this line after the while loop:
temp[i] = 0;
You are also copying
count
items from
temp
to
keys
. This will not generate a buffer overflow because you are only redaing from
temp
, but you may have garbage in
keys
when
i
<
count
.
There might be more errors that I have missed.