• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PUTC函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PUTC函数的典型用法代码示例。如果您正苦于以下问题:C++ PUTC函数的具体用法?C++ PUTC怎么用?C++ PUTC使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PUTC函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: wr_fputs

/*
 * wr_fputs - like fputs(), but makes control characters visible and
 *     turns \n into \r\n
 */
static void
wr_fputs(unsigned char *s)
{

#define	PUTC(c)	if (putchar(c) == EOF) err(1, NULL);

	for (; *s != '\0'; ++s) {
		if (*s == '\n') {
			PUTC('\r');
		} else if (((*s & 0x80) && *s < 0xA0) ||
			   /* disable upper controls */
			   (!isprint(*s) && !isspace(*s) &&
			    *s != '\a' && *s != '\b')
			  ) {
			if (*s & 0x80) {
				*s &= ~0x80;
				PUTC('M');
				PUTC('-');
			}
			if (iscntrl(*s)) {
				*s ^= 0x40;
				PUTC('^');
			}
		}
		PUTC(*s);
	}
	return;
#undef PUTC
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:33,代码来源:write.c


示例2: HTTPMakeResponse

/*	HTTPMakeResponse
**	----------------
**	Makes a HTTP/1.0-1.1 response header.
*/
PRIVATE int HTTPMakeResponse (HTStream * me, HTRequest * request)
{
    char crlf[3];
    HTRsHd response_mask = HTRequest_rsHd(request);
    *crlf = CR; *(crlf+1) = LF; *(crlf+2) = '\0';

    if (response_mask & HT_S_LOCATION) {		/* @@@ */

    }
    if (response_mask & HT_S_PROXY_AUTH) {		/* @@@ */

    }
    if (response_mask & HT_S_PUBLIC) {			/* @@@ */

    }
    if (response_mask & HT_S_RETRY_AFTER) {		/* @@@ */

    }
    if (response_mask & HT_S_SERVER) {
	PUTS("Server: ");
	PUTS(HTLib_appName());
	PUTC('/');
	PUTS(HTLib_appVersion());
	PUTC(' ');
	PUTS(HTLib_name());
	PUTC('/');
	PUTS(HTLib_version());
	PUTBLOCK(crlf, 2);
    }
    if (response_mask & HT_S_WWW_AUTH) {		/* @@@ */

    }
    HTTRACE(PROT_TRACE, "HTTP........ Generating Response Headers\n");
    return HT_OK;
}
开发者ID:BackupTheBerlios,项目名称:texlive,代码行数:39,代码来源:HTTPRes.c


示例3: lept_encode_utf8

static void lept_encode_utf8(lept_context* c, unsigned u) {
    if (u <= 0x7F) 
        PUTC(c, u & 0xFF);
    else if (u <= 0x7FF) {
        PUTC(c, 0xC0 | ((u >> 6) & 0xFF));
        PUTC(c, 0x80 | ( u       & 0x3F));
    }
开发者ID:Leungtamir,项目名称:json-tutorial,代码行数:7,代码来源:leptjson.c


示例4: wr_fputs

/*
 * wr_fputs - like fputs(), but makes control characters visible and
 *     turns \n into \r\n
 */
void
wr_fputs(char *s)
{

#define	PUTC(c)	if (putchar(c) == EOF) goto err;

	for (; *s != '\0'; ++s) {
		if (*s == '\n') {
			PUTC('\r');
			PUTC('\n');
			continue;
		}
		if (isu8cont(*s))
			continue;
		if (isprint(*s) || isspace(*s) || *s == '\a') {
			PUTC(*s);
		} else {
			PUTC('?');
		}

	}
	return;

err:	err(1, NULL);
#undef PUTC
}
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:30,代码来源:write.c


示例5: main

int main (int argc, char **argv)
{
    STATIC int w, h, bit_num;
    STATIC unsigned char byte_acc;
    STATIC int i;
	 STATIC int iter = 50;
    STATIC double x, y;
    STATIC double Zr, Zi, Cr, Ci, Tr, Ti;
    STATIC double limit = 2.0;

#ifdef COMMAND
    w = argc > 1 ? atoi(argv[1]) : 60;
	 h = argc > 2 ? atoi(argv[2]) : w;
#else
    w = h = 60;
#endif

    PRINTF3("P4\n%d %d\n",w,h);

TIMER_START();

    for(y=0;y<h;++y) 
    {
        for(x=0;x<w;++x)
        {
            Zr = Zi = Tr = Ti = 0.0;
            Cr = (2.0*x/w - 1.5); Ci=(2.0*y/h - 1.0);
        
            for (i=0;i<iter && (Tr+Ti <= limit*limit);++i)
            {
                Zi = 2.0*Zr*Zi + Ci;
                Zr = Tr - Ti + Cr;
                Tr = Zr * Zr;
                Ti = Zi * Zi;
            }
       
            byte_acc <<= 1; 
            if(Tr+Ti <= limit*limit) byte_acc |= 0x01;
                
            ++bit_num; 

            if(bit_num == 8)
            {
                PUTC(byte_acc,stdout);
                byte_acc = 0;
                bit_num = 0;
            }
            else if(x == w-1)
            {
                byte_acc <<= (8-w%8);
                PUTC(byte_acc,stdout);
                byte_acc = 0;
                bit_num = 0;
            }
        }
    }

TIMER_STOP();
}
开发者ID:z88dk,项目名称:z88dk,代码行数:59,代码来源:mandelbrot.c


示例6: _parse_entry_multivalue

static int _parse_entry_multivalue(struct vparse_state *state)
{
    state->entry->multivalue = 1;
    state->entry->v.values = strarray_new();

    NOTESTART();

    while (*state->p) {
        switch (*state->p) {
        /* only one type of quoting */
        case '\\':
            /* seen in the wild - \n split by line wrapping */
            if (state->p[1] == '\r') INC(1);
            if (state->p[1] == '\n') {
                if (state->p[2] != ' ' && state->p[2] != '\t')
                    return PE_BACKQUOTE_EOF;
                INC(2);
            }
            if (!state->p[1])
                return PE_BACKQUOTE_EOF;
            if (state->p[1] == 'n' || state->p[1] == 'N')
                PUTC('\n');
            else
                PUTC(state->p[1]);
            INC(2);
            break;

        case ';':
            strarray_appendm(state->entry->v.values, buf_dup_cstring(&state->buf));
            INC(1);
            break;

        case '\r':
            INC(1);
            break; /* just skip */
        case '\n':
            if (state->p[1] == ' ' || state->p[1] == '\t') {/* wrapped line */
                INC(2);
                break;
            }
            /* otherwise it's the end of the value */
            INC(1);
            goto out;

        default:
            PUTC(*state->p);
            INC(1);
            break;
        }
    }

out:
    /* reaching the end of the file isn't a failure here,
     * it's just another type of end-of-value */
    strarray_appendm(state->entry->v.values, buf_dup_cstring(&state->buf));
    return 0;
}
开发者ID:JensErat,项目名称:cyrus-imapd,代码行数:57,代码来源:vparse.c


示例7: bgl_write_string

/*---------------------------------------------------------------------*/
obj_t
bgl_write_string( obj_t o, bool_t esc, obj_t op ) {
   if( esc ) PUTC( op, '#' );
   
   PUTC( op, '"' );
   bgl_display_string( o, op );
   PUTC( op, '"' );

   return op;
}
开发者ID:mbrock,项目名称:bigloo-llvm,代码行数:11,代码来源:cwriter.c


示例8: cache_print_set

static FcBool
cache_print_set (FcFontSet *set, FcStrSet *dirs, const FcChar8 *base_name, FcBool verbose)
{
    FcChar8	    *dir;
    const FcChar8   *base;
    int		    n;
    int		    ndir = 0;
    FcStrList	    *list;

    list = FcStrListCreate (dirs);
    if (!list)
	goto bail2;
    
    while ((dir = FcStrListNext (list)))
    {
	base = file_base_name (base_name, dir);
	if (!write_string (stdout, base))
	    goto bail3;
	if (PUTC (' ', stdout) == EOF)
	    goto bail3;
	if (!write_int (stdout, 0))
	    goto bail3;
        if (PUTC (' ', stdout) == EOF)
	    goto bail3;
	if (!write_string (stdout, FC_FONT_FILE_DIR))
	    goto bail3;
	if (PUTC ('\n', stdout) == EOF)
	    goto bail3;
	ndir++;
    }
    
    for (n = 0; n < set->nfont; n++)
    {
	FcPattern   *font = set->fonts[n];
	FcChar8 *s;

	s = FcPatternFormat (font, (const FcChar8 *) "%{=fccat}\n");
	if (s)
	{
	    printf ("%s", s);
	    FcStrFree (s);
	}
    }
    if (verbose && !set->nfont && !ndir)
	printf ("<empty>\n");

    FcStrListDone (list);

    return FcTrue;

bail3:
    FcStrListDone (list);
bail2:
    return FcFalse;
}
开发者ID:Nathan22Miles,项目名称:SileLectionary,代码行数:55,代码来源:fc-cat.c


示例9: doprint

int doprint(char *fmt, va_list ap)
{
	int ret = 0;
	int code;
	int value = 0;
	char *p = NULL;
	char string[24] = { 0 };

	for (; ; ) {
		while (((code = *fmt) != '\0') && (code != '%')) {
			PUTC(code);
			fmt++;
			ret++;
		}
		if (code == '\0')
			goto out;

		switch (code = *++fmt) {
			case 'd':
				value = va_arg(ap, int);
				p = itoa(string, value, 24);
				break;
			case 'o':
				value = va_arg(ap, int);
				p = otoa(string, value, 24);
				break;
			case 'x':
				value = va_arg(ap, int);
				p = xtoa(string, value, 24);
				break;
			case 's':
				p = va_arg(ap, char *);
				break;
			case 'c':
				value = va_arg(ap, int);
				string[0] = (char )value;
				string[1] = '\0';
				p = string;
				break;
			default:
				p = NULL;
				break;
		}
		while (p && (*p != '\0')) {
			PUTC(*p);
			p++, ret++;
		}
		fmt++;
	}

out:
	return ret;
}
开发者ID:peterlintang,项目名称:c-language,代码行数:53,代码来源:7-3.c


示例10: process

void process (struct iop *io) {
	while (1) {
		int c = GETC (io);
		if (c == EOF) break;
		usleep (3000);
		PUTC (io, c);
		FLUSH (io);
	}
	if (io->fd == -1) {
		PUTC (io, '\n');
	}
}
开发者ID:apk,项目名称:bases,代码行数:12,代码来源:slocat.c


示例11: write_string

static FcBool
write_string (FILE *f, const FcChar8 *string)
{

    if (PUTC ('"', f) == EOF)
	return FcFalse;
    if (!write_chars (f, string))
	return FcFalse;
    if (PUTC ('"', f) == EOF)
	return FcFalse;
    return FcTrue;
}
开发者ID:Nathan22Miles,项目名称:SileLectionary,代码行数:12,代码来源:fc-cat.c


示例12: malloc

void CContainers::writeMemBuffers(int preprocFlag, int PPMDlib_order, int comprLevel, Encoder* PAQ_encoder, unsigned char* zlibBuffer,COutFileStream* outStream)
{
	std::map<std::string,CMemoryBuffer*>::iterator it;

	int fileLen=0;
	int len=0;
	int lenCompr=0;
	int allocated=0;

#ifdef USE_LZMA_LIBRARY
	if (IF_OPTION(OPTION_LZMA))
	{
		Byte **Data;
		size_t* Size;
		int count;
		
		count=(int)memmap.size();
		Size=new size_t[count];
		Data=(unsigned char**) malloc(sizeof(unsigned char*)*count);
		if (Data==NULL)
			OUT_OF_MEMORY();
	
		int i=0;
		for (it=memmap.begin(); it!=memmap.end(); it++)
		{
			CMemoryBuffer* b=it->second;
			fileLen=b->Size();
			
			if (fileLen>0)
			{
				Size[i]=fileLen;
				Data[i]=b->TargetBuf;
				i++;
				
				PUTC((int)it->first.size());
				for (int i=0; i<(int)it->first.size(); i++)
					PUTC(it->first[i]);
				
				PUTC(fileLen>>24);
				PUTC(fileLen>>16);
				PUTC(fileLen>>8);
				PUTC(fileLen);	
			}
		}
		
		PUTC(0);
		
		count=i;
		int last=LZMAlib_GetOutputFilePos(outStream);
		LZMAlib_EncodeSolidMemToFile(Data,Size,count,outStream);
		printStatus(0,LZMAlib_GetOutputFilePos(outStream)-last,true);
	}
开发者ID:Cristo-Conklin,项目名称:XWRT,代码行数:52,代码来源:MemBuffer.cpp


示例13: write_f_add_cr

static int
write_f_add_cr(void *vfp, char* buf, size_t len)
{
    size_t i;
    ASSERT(vfp);
    for (i = 0; i < len; i++) {
	if (buf[i] == '\n' && PUTC('\r', (FILE *) vfp) == EOF)
	    return get_error_result();
	if (PUTC(buf[i], (FILE *) vfp) == EOF)
	    return get_error_result();
    }
    return 0;
}
开发者ID:AlainODea,项目名称:otp,代码行数:13,代码来源:erl_printf.c


示例14: process

void process (struct iop *io) {
	while (1) {
		int d;
		int c = GETC (io);
		if (c == EOF) break;
		if (c >= '!' && c <= '~') {
			c = ('!' + '~') - c;
		}
		PUTC (io, c);
	}
	if (io->fd == -1) {
		PUTC (io, '\n');
	}
}
开发者ID:apk,项目名称:bases,代码行数:14,代码来源:inv94.c


示例15: kgdb_recv

/*
 * Receive a packet.
 */
static int
kgdb_recv(u_char *bp, int maxlen)
{
	u_char *p;
	int c, csum;
	int len;

	do {
		p = bp;
		csum = len = 0;
		while ((c = GETC()) != KGDB_START)
			;

		while ((c = GETC()) != KGDB_END && len < maxlen) {
			c &= 0x7f;
			csum += c;
			*p++ = c;
			len++;
		}
		csum &= 0xff;
		*p = '\0';

		if (len >= maxlen) {
			PUTC(KGDB_BADP);
			continue;
		}

		csum -= digit2i(GETC()) * 16;
		csum -= digit2i(GETC());

		if (csum == 0) {
			PUTC(KGDB_GOODP);
			/* Sequence present? */
			if (bp[2] == ':') {
				PUTC(bp[0]);
				PUTC(bp[1]);
				len -= 3;
				kgdb_copy(bp + 3, bp, len);
			}
			break;
		}
		PUTC(KGDB_BADP);
	} while (1);
#ifdef	DEBUG_KGDB
	printf("kgdb_recv: %s\n", bp);
#endif
	return (len);
}
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:51,代码来源:kgdb_stub.c


示例16: ARGS2

void showDiags ARGS2(
	HTStream *, 		target,
	diagnosticRecord **, 	d)
{
  long i;

  for (i = 0; d[i] != NULL; i++) {
    if (d[i]->ADDINFO != NULL) {
      PUTS("Diagnostic code is ");
      PUTS(d[i]->DIAG);
      PUTC(' ');
      PUTS(d[i]->ADDINFO);
      PUTC('\n'); ;
    }
  }
}
开发者ID:JGunning,项目名称:Spyglass-mosaic,代码行数:16,代码来源:HTWAIS.c


示例17: PUTC

simple_output &simple_output::put_raw_char(char c)
{
  col += last_word.flush(fp);
  PUTC(c, fp);
  col++;
  return *this;
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:7,代码来源:output.cpp


示例18: while

simple_output &simple_output::copy_file(FILE *infp)
{
  int c;
  while ((c = getc(infp)) != EOF)
    PUTC(c, fp);
  return *this;
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:7,代码来源:output.cpp


示例19: display_line

/*	Output a line
**	-------------
*/
PRIVATE void display_line (HText * text, HTLine * line)
{
#ifdef CURSES
      int     y, x;

      waddstr(w_text, SPACES(line->offset));
      waddstr(w_text, line->data);
      getyx(w_text, y, x);
      if (y < DISPLAY_LINES-1) {
              wmove(w_text, ++y, 0);
      }
#else
   if (!text->target)
   {
#ifdef CYRILLIC
       /* HWL 18/7/94: applied patch from [email protected] (Anton Tropashko) */
       a_print(SPACES(line->offset),H,stdout); 
       a_print(line->data,H,stdout);
       fputc('\n',stdout);
#else
       OutputData(LineMode_getView(text->pLm), "%s%s\n", SPACES(line->offset), line->data);
#endif
   }
   else {
       PUTS(SPACES(line->offset));
       PUTS(line->data);
       PUTC('\n');
   }
#endif
   
}
开发者ID:svagionitis,项目名称:libwww,代码行数:34,代码来源:GridText.c


示例20: NetToText_put_block

/*	Converter from CRLF to \n
**	-------------------------
**	The input is assumed to be in local representation with lines
**	delimited by (CR,LF) pairs in the local representation.
**	The conversion to local representation is always done in HTSocket.c
**	The (CR,LF) sequence when found is changed to a '\n' character,
**	the internal C representation of a new line.
*/
PRIVATE int NetToText_put_block (HTStream * me, const char * s, int l)
{
    int status;
    if (!me->start)
	me->start = s;
    else {
	l -= (me->start - s);
	s = me->start;
    }
    while (l-- > 0) {
	if (me->had_cr && *s == LF) {
	    if (s > me->start+1) {
		if ((status = PUTBLOCK(me->start, s - me->start-1)) != HT_OK)
		    return status;
	    }
	    me->start = s+1;
	    if ((status = PUTC('\n')) != HT_OK)
		return status;
	}
	me->had_cr = (*s++ == CR);
    }
    if (me->start < s && (status = PUTBLOCK(me->start, s-me->start)) != HT_OK)
	return status;
    me->start = NULL;			      /* Whole buffer is written :-) */
    return HT_OK;
}
开发者ID:BackupTheBerlios,项目名称:texlive,代码行数:34,代码来源:HTNetTxt.c



注:本文中的PUTC函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PUTCHAR函数代码示例发布时间:2022-05-30
下一篇:
C++ PUT32函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap