Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Why ~ Appers At Output?

$
0
0
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:

#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?
Posted Image
Why does it do so?
Thanks.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>