当前位置: 首页>>代码示例>>C++>>正文


C++ Putc函数代码示例

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


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

示例1: while

char *gets(int channel, char *buf, uint32_t len) {
    int ch;
    uint32_t nread;

    nread = 0;
    while ((ch = Getc(channel))) {
        if (ch == LF || ch == CR || ch == EOF) {
            Putc(IO, '\n');
            break;
        } else if (ch == BS || ch == '\b') {
            if (nread > 0) {
                if (nread < len) {
                    buf--;
                }
                nread--;
                bufputstr(IO, "\b \b");
            }
        } else {
            if (nread < len) {
                *buf++ = ch;
            }
            nread++;
            Putc(IO, ch);
        }
    }
    *buf = 0;
    return buf;
}
开发者ID:hkpeprah,项目名称:cs452-microkern,代码行数:28,代码来源:stdio.c

示例2: get_sensor

int get_sensor(int unit, char buff[2]) {
	Putc(COM1, 192+unit); //dump sensor unit memory into computer
	buff[1] = Getc(COM1);
	buff[2] = Getc(COM2);
	Putc(COM1, 192); //reset sensor unit
	return 0;
}
开发者ID:ohasanliUW,项目名称:TrainControlSystem,代码行数:7,代码来源:sensor_task.c

示例3: copy_with_maybe_case_conversion

/* This function copies len characters from src to dst, possibly applying case conversions to them: if convertCase is 1, to upper case and if it is -1, to lower
 * case. If convertNextOnly is 1, only a single character is converted (and convertCase is reset), otherwise all of them are. */
static void copy_with_maybe_case_conversion(String *dst, const char *src, int len, int *convertCase, int convertNextOnly)
{
  /* Deal with the trivial cases first. */
  if (!len)
    return;

  if (!*convertCase) {
      Write(dst, src, len);
      return;
  }

  /* If we must convert only the first character, do it and write the rest at once. */
  if (convertNextOnly) {
    int src_char = *src;
    Putc(*convertCase == 1 ? toupper(src_char) : tolower(src_char), dst);
    *convertCase = 0;
    if (len > 1) {
      Write(dst, src + 1, len - 1);
    }
  } else {
    /* We need to convert all characters. */
    int i;
    for (i = 0; i < len; i++, src++) {
      int src_char = *src;
      Putc(*convertCase == 1 ? toupper(src_char) : tolower(src_char), dst);
    }
  }
}
开发者ID:EemeliSyynimaa,项目名称:yam2d,代码行数:30,代码来源:misc.c

示例4: NewStringEmpty

String *Swig_string_escape(String *s) {
  String *ns;
  int c;
  ns = NewStringEmpty();

  while ((c = Getc(s)) != EOF) {
    if (c == '\n') {
      Printf(ns, "\\n");
    } else if (c == '\r') {
      Printf(ns, "\\r");
    } else if (c == '\t') {
      Printf(ns, "\\t");
    } else if (c == '\\') {
      Printf(ns, "\\\\");
    } else if (c == '\'') {
      Printf(ns, "\\'");
    } else if (c == '\"') {
      Printf(ns, "\\\"");
    } else if (c == ' ') {
      Putc(c, ns);
    } else if (!isgraph(c)) {
      if (c < 0)
	c += UCHAR_MAX + 1;
      Printf(ns, "\\%o", c);
    } else {
      Putc(c, ns);
    }
  }
  return ns;
}
开发者ID:EemeliSyynimaa,项目名称:yam2d,代码行数:30,代码来源:misc.c

示例5: mangle_namestr

static void mangle_namestr(String *mangled, SwigType *t) {
  int length = Len(t);
  if (SwigType_isqualifier(t)) {
    Append(mangled, "q_");
    mangle_stringcopy(mangled, Char(t)+2, length-4);
    Append(mangled, "__");
  } else if (SwigType_ismemberpointer(t)) {
    Append(mangled, "m_");
    mangle_stringcopy(mangled, Char(t)+2, length-4);
    Append(mangled, "__");
  } else if (SwigType_isarray(t)) {
    Append(mangled, "a_");
    mangle_stringcopy(mangled, Char(t)+2, length-4);
    Append(mangled, "__");
  } else if (SwigType_isfunction(t)) {
    List *p = SwigType_parmlist(t);
    int sz = Len(p);
    int i;
    Append(mangled, "f_");
    for (i = 0; i < sz; i++) {
      mangle_subtype(mangled, Getitem(p, i));
      Putc('_', mangled);
    }
    Append(mangled, (sz > 0) ? "_" : "__");
  } else if (SwigType_isvarargs(t)) {
    Append(mangled, "___");
  } else {
    char *d = Char(t);
    char *c = strstr(d, "<(");
    if (!c || !strstr(c + 2, ")>")) {
      /* not a template type */
      mangle_stringcopy(mangled, Char(t), Len(t));
    } else {
      /* a template type */
      String *suffix;
      List *p;
      int i, sz;
      mangle_stringcopy(mangled, d, c-d);
      Putc('T', mangled);
      Putc('_', mangled);

      p = SwigType_parmlist(c + 1);
      sz = Len(p);
      for (i = 0; i < sz; i++) {
	mangle_subtype(mangled, Getitem(p, i));
	Putc('_', mangled);
      }
      Putc('t', mangled);
      suffix = SwigType_templatesuffix(t);
      if (Len(suffix) > 0) {
	mangle_namestr(mangled, suffix);
      } else {
	Append(mangled, suffix);
      }
      Delete(suffix);
      Delete(p);
    }
  }
}
开发者ID:Distrotech,项目名称:swig,代码行数:59,代码来源:stype.c

示例6: putw

void putw( int server, int channel, int n, char fc, char *bf ) {
	char ch;
	char *p = bf;

	while( *p++ && n > 0 ) n--;
	while( n-- > 0 ) Putc( server, channel, fc );
	while( ( ch = *bf++ ) ) Putc( server, channel, ch );
}
开发者ID:guangyuwangg,项目名称:REAL-TIME-TRAINS,代码行数:8,代码来源:io.c

示例7: scanner_locator

static void
scanner_locator(String *loc) {
  int c;
  Locator *l;
  Seek(loc,1,SEEK_SET);
  c = Getc(loc);
  if (c == '@') {
    /* Empty locator.  We pop the last location off */
    if (locs) {
      cparse_file = locs->filename;
      cparse_line = locs->line_number;
      l = locs->next;
      free(locs);
      locs = l;
    }
    /*    Printf(stderr,"location: %s:%d\n",cparse_file,cparse_line);*/
    return;
  }

  /* We're going to push a new location */
  l = (Locator *) malloc(sizeof(Locator));
  l->filename = cparse_file;
  l->line_number = cparse_line;
  l->next = locs;
  locs = l;
  
  /* Now, parse the new location out of the locator string */
  {
    String *fn = NewString("");
    Putc(c,fn);
    
    while ((c = Getc(loc)) != EOF) {
      if ((c == '@') || (c == ',')) break;
      Putc(c,fn);
    }

    cparse_file = Swig_copy_string(Char(fn));
    Clear(fn);
  
    cparse_line = 1;
    /* Get the line number */
    while ((c = Getc(loc)) != EOF) {
      if ((c == '@') || (c == ',')) break;
      Putc(c,fn);
    }

    cparse_line = atoi(Char(fn));
    Clear(fn);

    /* Get the rest of it */
    while (( c= Getc(loc)) != EOF) {
      if (c == '@') break;
      Putc(c,fn);
    }
    /*  Printf(stderr,"location: %s:%d\n",cparse_file,cparse_line); */
    Delete(fn);
  }
}
开发者ID:janearc,项目名称:posixnap_old,代码行数:58,代码来源:cscanner.c

示例8: trainSensorNotifier

void trainSensorNotifier() {
	int i;
	int parent_tid = MyParentTid();
	int com1_tid = WhoIs(COM1_REG_NAME);

	int sensor_next = 0;
	int data_changed = TRUE;
	char query = SENSOR_READ_MULTI + SENSOR_DECODER_TOTAL;

	SensorMsg msg;
	msg.type = SENSOR_DATA;
	for(i = 0; i < SENSOR_BYTES_TOTAL; i++) {
		msg.sensor_data[i] = 0;
	}
	
	/* Filter out left over sensor data */
	while(1) {
		if(sensor_next == 0 && data_changed) {
			Putc(com1_tid, query);
			data_changed = 0;
		}
		else break;

		int new_data = Getc(com1_tid);
		assert(new_data >= 0, "Fail to get");
		if(new_data != 0) data_changed = TRUE;

		sensor_next = (sensor_next + 1) % SENSOR_BYTES_TOTAL;
	}

	data_changed = FALSE;

	Putc(com1_tid, SENSOR_AUTO_RESET);
	while(1) {
		if(sensor_next == 0) {
			if(data_changed) {
				data_changed = FALSE;
				// Deliver sensor data to the parent
				Send(parent_tid, (char *)(&msg), SENSOR_BYTES_TOTAL, NULL, 0);
			}
			// Request sensor data again
			Putc(com1_tid, query);
		}

		// Get and save new data
		int new_data = Getc(com1_tid);
		assert(new_data >= 0, "Fail to get");
		if(msg.sensor_data[sensor_next] != new_data) {
			msg.sensor_data[sensor_next] = new_data & 0xff;
			data_changed = TRUE;
		}

		// Increment the counter
		sensor_next = (sensor_next + 1) % SENSOR_BYTES_TOTAL;
	}
}
开发者ID:gregwym,项目名称:ARM-Micro-Kernel,代码行数:56,代码来源:train_sensor.c

示例9: format

void format ( int server, int channel, char *fmt, va_list va ) {
	char bf[12];
	char ch, lz;
	int w;

	
	while ( ( ch = *(fmt++) ) ) {
		if ( ch != '%' )
			Putc( server, channel, ch );
		else {
			lz = 0; w = 0;
			ch = *(fmt++);
			switch ( ch ) {
			case '0':
				lz = 1; ch = *(fmt++);
				break;
			case '1':
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
			case '7':
			case '8':
			case '9':
				ch = a2i( ch, &fmt, 10, &w );
				break;
			}
			switch( ch ) {
			case 0: return;
			case 'c':
				Putc( server, channel, va_arg( va, char ) );
				break;
			case 's':
				putw( server, channel, w, 0, va_arg( va, char* ) );
				break;
			case 'u':
				ui2a( va_arg( va, unsigned int ), 10, bf );
				bwputw( channel, w, lz, bf );
				break;
			case 'd':
				i2a( va_arg( va, int ), bf );
				putw( server, channel, w, lz, bf );
				break;
			case 'x':
				ui2a( va_arg( va, unsigned int ), 16, bf );
				putw( server, channel, w, lz, bf );
				break;
			case '%':
				Putc( server, channel, ch );
				break;
			}
		}
	}
}
开发者ID:guangyuwangg,项目名称:REAL-TIME-TRAINS,代码行数:55,代码来源:io.c

示例10: get_many_sensor

int get_many_sensor(int num_of_units, char *buff, int *last_sensor_req_time, int *approx_hit_time) {
	Putc(COM1, 128+num_of_units);
	//Printf(COM2, "get_many_sensor: Sensors requested\n\r");
	int i =0;
	int sensor_req_time = Time();
	for(i=0; i<2*num_of_units; i+=2) {
		buff[i] = Getc(COM1);
		buff[i+1] = Getc(COM1);
	}
	*approx_hit_time = ((*last_sensor_req_time + sensor_req_time + 1)/2);
	Putc(COM1, 192);
	*last_sensor_req_time = sensor_req_time; 
	return 0;
}
开发者ID:ohasanliUW,项目名称:TrainControlSystem,代码行数:14,代码来源:sensor_task.c

示例11: do_write2

static word
do_write2(term_t stream, term_t term, int flags)
{ GET_LD
  IOSTREAM *s;

  if ( getTextOutputStream(stream, &s) )
  { write_options options;
    int rc;

    memset(&options, 0, sizeof(options));
    options.flags     = flags;
    options.out	      = s;
    options.module    = MODULE_user;
    if ( options.module
#ifndef __YAP_PROLOG__
	 && True(options.module, M_CHARESCAPE)
#endif
	 )
      options.flags |= PL_WRT_CHARESCAPES;
    if ( truePrologFlag(PLFLAG_BACKQUOTED_STRING) )
      options.flags |= PL_WRT_BACKQUOTED_STRING;

    PutOpenToken(EOF, s);		/* reset this */
    rc = writeTopTerm(term, 1200, &options);
    if ( rc && (flags&PL_WRT_NEWLINE) )
      rc = Putc('\n', s);

    return streamStatus(s) && rc;
  }

  return FALSE;
}
开发者ID:gokhansolak,项目名称:yap-6.3,代码行数:32,代码来源:pl-write.c

示例12: NewStringEmpty

String *replace_captures(const char *input, String *subst, int captures[])
{
  String *result = NewStringEmpty();
  const char *p = Char(subst);

  while (*p) {
    /* Copy part without substitutions */
    const char *q = strchr(p, '\\');
    if (!q) {
      Write(result, p, strlen(p));
      break;
    }
    Write(result, p, q - p);
    p = q + 1;

    /* Handle substitution */
    if (*p == '\0') {
      Putc('\\', result);
    } else if (isdigit(*p)) {
      int group = *p++ - '0';
      int l = captures[group*2], r = captures[group*2 + 1];
      if (l != -1) {
        Write(result, input + l, r - l);
      }
    }
  }

  return result;
}
开发者ID:JensMunkHansen,项目名称:swig-matlab,代码行数:29,代码来源:misc.c

示例13: NewStringEmpty

String *replace_captures(int num_captures, const char *input, String *subst, int captures[], String *pattern, String *s)
{
  String *result = NewStringEmpty();
  const char *p = Char(subst);

  while (*p) {
    /* Copy part without substitutions */
    const char *q = strchr(p, '\\');
    if (!q) {
      Write(result, p, strlen(p));
      break;
    }
    Write(result, p, q - p);
    p = q + 1;

    /* Handle substitution */
    if (*p == '\0') {
      Putc('\\', result);
    } else if (isdigit((unsigned char)*p)) {
      int group = *p++ - '0';
      if (group < num_captures) {
	int l = captures[group*2], r = captures[group*2 + 1];
	if (l != -1) {
	  Write(result, input + l, r - l);
	}
      } else {
	Swig_error("SWIG", Getline(s), "PCRE capture replacement failed while matching \"%s\" using \"%s\" - request for group %d is greater than the number of captures %d.\n",
	    Char(pattern), input, group, num_captures-1);
      }
    }
  }

  return result;
}
开发者ID:Distrotech,项目名称:swig,代码行数:34,代码来源:misc.c

示例14: PutOpenToken

static int
PutOpenToken(int c, IOSTREAM *s)
{ if ( needSpace(c, s) )
  { TRY(Putc(' ', s));
    return TRUE_WITH_SPACE;
  }

  return TRUE;
}
开发者ID:gokhansolak,项目名称:yap-6.3,代码行数:9,代码来源:pl-write.c

示例15: test2

/* Alternative implementation for manglestr_default. Mangling is similar to the original
   except for a few subtle differences for example in templates:
    namespace foo {
      template<class T> class bar {};
      typedef int Integer;
      void test2(bar<Integer *> *x);
    }
    Mangling is more consistent and changes from 
    _p_foo__barT_int_p_t to 
    _p_foo__barT_p_int_t.
*/
static void mangle_stringcopy(String *destination, const char *source, int count) {
  while (count-- > 0) {
    char newc = '_';
    if (!(*source == '.' || *source == ':' || *source == ' '))
      newc = *source;
    /* TODO: occasionally '*' or numerics need converting to '_', eg in array dimensions and template expressions */
    Putc(newc, destination);
    source++;
  }
}
开发者ID:Distrotech,项目名称:swig,代码行数:21,代码来源:stype.c


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