How to input "EOF" signal in unix?

In this simple program count.c,

#include<stdio.h>
int main(int argc,char *argv[])
{
     int c,i;
     i=0;
    while((c=getchar()) != EOF )
    {
        if(c=='/n')
            ++i;
    }
     printf("%d/n",i);
}
  1. The terminal  shows "linker input file unused because linking not done"  When i compile the program with "gcc -Wall -c count count.c" .   And i execute the program count, "Ctrl+D" will not work. And later i know that the option -c is wrong. 
  2. I am not sure exactly what causes this problem. But you can ignore this as you just started with simple programs and not linking any libraries while compiling.

    Can you try 
    Code:
    gcc -c -Wall -o file file.c

    This command is producing the same error as you posted.

    But without option "-c" it works fine for me. (this option stops the compiler from invoking the linker. But you have not mentioned this option but still getting this error seems to odd.
  3. The result, i got two question , "EOF" signal in uinx is "Ctrl+D" and  www.unix.com . Thanks.

 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值