I know ~ is my compilers way to represent something but what is it? I was told to write a function that would clean up newlines, tabs and spaces from a given line. here's what I wrote:
My code runs perfectly except for the ~ it prints?
![Posted Image]()
Why does it do so?
Thanks.
#include <stdio.h>
#define MAXLINE 1000
int getline(char[]);
int main()
{
char line[MAXLINE];
getline(line);
int i = 0;
while(line[i] != '\0')
{
printf("%c", line[i]);
i++;
}
return 0;
}
int getline(char line[])
{
int i = 0;
while(i < MAXLINE && scanf("%c", &line[i]) == 1)
{
if(line[i] == ' ' || line[i] == '\n' || line[i] =='\t')
{
i--;
}
i++;
}
line[i] == '\0';
return 0;
}
My code runs perfectly except for the ~ it prints?

Why does it do so?
Thanks.