使用STDPRN C语言编译错误 [英] C compilation errors on using stdprn

查看:389
本文介绍了使用STDPRN C语言编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的操作系统是:Windows 8的

My OS is: Windows 8

IDE:VS 2012

IDE: VS 2012

下面是我的C程序。 (从书)

Here is my C program. (from book)

/* print_it.c—This program prints a listing with line numbers! */
#include <stdlib.h>
#include <stdio.h>

void do_heading(char *filename);

int line = 0, page = 0;

int main( int argv, char *argc[] )
{
  char buffer[256];
  FILE *fp;

  if( argv < 2 ) 
  {
    fprintf(stderr, "\nProper Usage is: " );
    fprintf(stderr, "\n\nprint_it filename.ext\n" );
    return(1);
  }

  if (( fp = fopen( argc[1], "r" )) == NULL )
  {
    fprintf( stderr, "Error opening file, %s!", argc[1]);
    return(1);
  }

  page = 0;
  line = 1;
  do_heading( argc[1]);

  while( fgets( buffer, 256, fp ) != NULL )
  {
    if( line % 55 == 0 ) 
      do_heading( argc[1] );
    fprintf( stdprn, "%4d:\t%s", line++, buffer );
  }

  fprintf( stdprn, "\f" );
  fclose(fp);
  return 0;
}

void do_heading( char *filename )
{
  page++;

  if ( page > 1)
    fprintf( stdprn, "\f" );

  fprintf( stdprn, "Page: %d, %s\n\n", page, filename );
}

尝试编译。开业开发命令提示符,和类型

Trying to compile. Opened Developer Command Prompt, and typed

cl print_it.c

得到这个屏幕(错误和警告的串)

Got this screen (bunch of errors and warnings)

在这里输入的形象描述

我是什么失踪?

推荐答案

STDPRN 也不是标准C. STDPRN的一部分编译器中提供的DOS流。也许应该是可以避免的。

stdprn isn't part of standard C. stdprn is a stream DOS compilers provided. Should probably be avoided.

您可以尝试的关闭的ANSI兼容性即可获得 STDPRN 工作。
参考

You could try turning off ANSI compatibility to get stdprn to work. (Reference)

这篇关于使用STDPRN C语言编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆