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


C++ printint函数代码示例

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


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

示例1: main

int main()
{
   int n = 5;
   printint(recurfact(n));

   printint(iterfact(n));
}
开发者ID:nburfield,项目名称:CS660-Compiler-Construction,代码行数:7,代码来源:iterfact.c

示例2: semafor_down

void semafor_down()
{
	int* shmem = get_mem();

	fore(getpid());
	print("Proceso 1 intenta bajar semaforo\n");

	sem_down();

	fore(getpid());
	print("Proceso 1 baja semaforo:\n");
	print("    Variable en shared memory tiene valor:\n");
	print("    ");
	printint(*shmem);
	*shmem = *shmem + 2;
	print("\n    Se le suma 2 y ahora tiene valor:\n");
	print("    ");
	printint(*shmem);
	print("\n");

	sleep(5);

	sem_up();
	fore(getpid());
	print("Proceso 1 levanta semaforo\n");

	fore(getppid());
	while(1);
}
开发者ID:jpdantur,项目名称:SO2,代码行数:29,代码来源:processes.c

示例3: main

void main()
{
   int x;

   a[0] = 12;
   a[1] = 10;
   a[2] = 8;
   a[3] = 6;
   a[4] = 4;
   a[5] = 2;

   x = a[5];
   printint(x);    // 2
   printchar(10);

   printint(a[0]);  // 12
   printchar(10);

   printint(10+a[1]);  // 20
   printchar(10);

   x = a[2]*10 + a[3] + a[4];
   printint(x);  // should be 90
   printchar(10);

}
开发者ID:Caskman,项目名称:Clike-Compiler,代码行数:26,代码来源:array1.c

示例4: mal

// makeslice(nel int, cap int, width int) (ary []any);
void
runtime·makeslice(uint32 nel, uint32 cap, uint32 width, Slice ret)
{
	uint64 size;

	if(cap < nel)
		cap = nel;
	size = cap*width;

	ret.len = nel;
	ret.cap = cap;
	ret.array = mal(size);

	FLUSH(&ret);

	if(debug) {
		prints("makeslice: nel=");
		runtime·printint(nel);
		prints("; cap=");
		runtime·printint(cap);
		prints("; width=");
		runtime·printint(width);
		prints("; ret=");
		runtime·printslice(ret);
		prints("\n");
	}
}
开发者ID:8l,项目名称:go-learn,代码行数:28,代码来源:slice.c

示例5: FLUSH

// slicecopy(to any, fr any, wid uint32) int
void
runtime·slicecopy(Slice to, Slice fm, uintptr width, int32 ret)
{
	if(fm.len == 0 || to.len == 0 || width == 0) {
		ret = 0;
		goto out;
	}

	ret = fm.len;
	if(to.len < ret)
		ret = to.len;

	if(ret == 1 && width == 1) {	// common case worth about 2x to do here
		*to.array = *fm.array;	// known to be a byte pointer
	} else {
		runtime·memmove(to.array, fm.array, ret*width);
	}

out:
	FLUSH(&ret);

	if(debug) {
		runtime·prints("main·copy: to=");
		runtime·printslice(to);
		runtime·prints("; fm=");
		runtime·printslice(fm);
		runtime·prints("; width=");
		runtime·printint(width);
		runtime·prints("; ret=");
		runtime·printint(ret);
		runtime·prints("\n");
	}
}
开发者ID:Ahmah2009,项目名称:golang,代码行数:34,代码来源:slice.c

示例6: printint

//printing function
void printint(int x) {
  if(x < 0) {
    putchar(45);
    x = -1*x;
    if (x == 0) {
      putchar(0);
    }
    else {
      int i = 0;
      i = x % 10 + 48;
      printint(x/10);
      putchar(i);
    }
  }
  else {
    if (x == 0) {
      putchar(0);
    }
    else {
      int i = 0;
      i = x % 10 + 48;
      printint(x/10);
      putchar(i);
    }
  }
}
开发者ID:hpmsora,项目名称:C-Language-Computer-Structure-C335,代码行数:27,代码来源:myprintf.c

示例7: print

/*
*	Mesma função do printf no C. Recebe uma String e a posição a ser impresso
*	x e y; A string contem marcas que são substituidos pelos valores passados;
*	Possui suporte para:
*		%d Inteiro
*		%b Binário de um inteiro
*		%x Hexadecimal de um inteiro
*		%c Caracter
*		%s String
*		%% Valor de %
*		\n Quebra de linha
*		
*/
void print(const char *str,int x, int y,...){

	char *video = ((char *) VIDEO) + 160 * x + y;

	char *s;

	
	va_list va = (char*)(&y + 1);
	while(*str != 0){
		if(*str != '%'){
			
			if(*str == 0x0a){	// Quebra de linha "\n"
				int v = (int)(video - VIDEO);
				video+=160-(v-160*(v/160));
			}else{
	 	        	printc(*str,video);
			}			
			str++;
			


		}else {
		
			switch(*++str)
			{
				case 'd':
					video = printint(getInt(va),video,10);
					next_arg(va,int);
					break;
				case 'c':
					printc((char)*va,video);
					next_arg(va,int);
					break;
				case 'x':
					video = printint(getInt(va),video,16);
					next_arg(va,int);
					break;
				case 'b':
					video = printint(getInt(va),video,2);
					next_arg(va,int);
					break;
				case '%':
					printc('%',video);
					break;
				case 's':
					s = (char*) (getInt(va));
					while(*s != 0){
						printc((char)*s++,video);
					}
					next_arg(va,int);
					break;
				
			}
			
			str++;	
		}
	}
}
开发者ID:joao29a,项目名称:boot,代码行数:71,代码来源:screen.c

示例8: cprintf

// Print to the console. only understands %d, %x, %p, %s.
void
cprintf(char *fmt, ...)
{
  int i, c;
  int locking;
  uint *argp;
  char *s;

  locking = cons.locking;
  if(locking)
    acquire(&cons.lock);

  if (fmt == 0)
    panic("null fmt");

  argp = (uint *)(void*)(&fmt + 1);
  for(i = 0; (c = fmt[i] & 0xff) != 0; i++){
    if(c != '%'){
    //    gpuputc(c);
	uartputc(c);
      continue;
    }
    c = fmt[++i] & 0xff;
    if(c == 0)
      break;
    switch(c){
    case 'd':
      printint(*argp++, 10, 1);
      break;
    case 'x':
    case 'p':
      printint(*argp++, 16, 0);
      break;
    case 's':
      if((s = (char*)*argp++) == 0)
        s = "(null)";
      for(; *s; s++){
      //  gpuputc(*s);
	uartputc(*s);
      }
      break;
    case '%':
//	gpuputc('%');
	uartputc('%');
      break;
    default:
      // Print unknown % sequence to draw attention.
//	gpuputc('%');
	uartputc('%');
//	gpuputc(c);
	uartputc(c);
      break;
    }
  }
  if(locking)
    release(&cons.lock);
}
开发者ID:Lulkafe,项目名称:xv6_rpi_port,代码行数:58,代码来源:console.c

示例9: __attribute__

__attribute__ ((noinline)) void uip_printip4(const uip_ipaddr_t ip4) {
	printint(uip_ipaddr1(ip4));
	printstr(".");
	printint(uip_ipaddr2(ip4));
	printstr(".");
	printint(uip_ipaddr3(ip4));
	printstr(".");
	printint(uip_ipaddr4(ip4));
}
开发者ID:colinbroad,项目名称:sc_xtcp,代码行数:9,代码来源:uip_server_support.c

示例10: cprintf

// Print to the console. only understands %d, %x, %p, %s.
void
cprintf(char *fmt, ...)
{
  int i, c, state, locking;
  uint *argp;
  char *s;

  locking = cons.locking;
  if(locking)
    acquire(&cons.lock);

  if (fmt == 0)
    panic("null fmt");

  argp = (uint*)(void*)(&fmt + 1);
  state = 0;
  for(i = 0; (c = fmt[i] & 0xff) != 0; i++){
    if(c != '%'){
      consputc(c);
      continue;
    }
    c = fmt[++i] & 0xff;
    if(c == 0)
      break;
    switch(c){
    case 'd':
      printint(*argp++, 10, 1);
      break;
    case 'x':
    case 'p':
      printint(*argp++, 16, 0);
      break;
    case 's':
      if((s = (char*)*argp++) == 0)
        s = "(null)";
      for(; *s; s++)
        consputc(*s);
      break;
    case '%':
      consputc('%');
      break;
    case 'o':
      // hw1: fill in your code here. 
      // print a number in octal system
      printint(*argp++, 8, 0);
      break;
    default:
      // Print unknown % sequence to draw attention.
      consputc('%');
      consputc(c);
      break;
    }
  }

  if(locking)
    release(&cons.lock);
}
开发者ID:KWMalik,项目名称:Homework-4,代码行数:58,代码来源:console.c

示例11: cprintf

// Print to the console. only understands %d, %x, %p, %s.
void
cprintf(char *fmt, ...)
{
    int i, c, state, locking;
    uint *argp;
    char *s;

    locking = use_console_lock;
    if(locking)
        acquire(&console_lock);

    argp = (uint*)(void*)&fmt + 1;
    state = 0;
    for(i = 0; fmt[i]; i++) {
        c = fmt[i] & 0xff;
        switch(state) {
        case 0:
            if(c == '%')
                state = '%';
            else
                cons_putc(c);
            break;

        case '%':
            switch(c) {
            case 'd':
                printint(*argp++, 10, 1);
                break;
            case 'x':
            case 'p':
                printint(*argp++, 16, 0);
                break;
            case 's':
                s = (char*)*argp++;
                if(s == 0)
                    s = "(null)";
                for(; *s; s++)
                    cons_putc(*s);
                break;
            case '%':
                cons_putc('%');
                break;
            default:
                // Print unknown % sequence to draw attention.
                cons_putc('%');
                cons_putc(c);
                break;
            }
            state = 0;
            break;
        }
    }

    if(locking)
        release(&console_lock);
}
开发者ID:pi0,项目名称:os-xv6-network,代码行数:57,代码来源:console.c

示例12: printvarg

static int printvarg(int *varg)
{
	char scr[2];

	char *format = (char *)(*varg++);
	int pc = 0;

	for (; *format != 0; ++format) {
		if (*format == '%') {
			++format;
			if (*format == '\0')
				break;

			if (*format == '%')
				goto symbol;

			if( *format == 's' ) {
				char *s = *((char **)varg++);
				pc += printstr(s ? s : "(null)");
				continue;
			}

			if( *format == 'd' ) {
				pc += printint(*varg++, 10, 1, 'a');
				continue;
			}

			if( *format == 'x' ) {
				pc += printint(*varg++, 16, 0, 'a');
				continue;
			}

			if( *format == 'X' ) {
				pc += printint(*varg++, 16, 0, 'A');
				continue;
			}

			if( *format == 'u' ) {
				pc += printint(*varg++, 10, 0, 'a');
				continue;
			}

			if( *format == 'c' ) {
				scr[0] = *varg++;
				scr[1] = '\0';
				pc += printstr(scr);
				continue;
			}
		} else {
		symbol:
			pc += printchar(*format);
		}
	}

	return pc;
}
开发者ID:geomatsi,项目名称:Pandaboard-FreeRTOS,代码行数:56,代码来源:trace.c

示例13:

void
runtime·printslice(Slice a)
{
	runtime·prints("[");
	runtime·printint(a.len);
	runtime·prints("/");
	runtime·printint(a.cap);
	runtime·prints("]");
	runtime·printpointer(a.array);
}
开发者ID:abustany,项目名称:go,代码行数:10,代码来源:slice.c

示例14: tick_clock

void tick_clock(struct tm *tick_time, bool stop) {
  clear();
  if((sw_butt&4)==4) { 
    reg.tm_hour = 0;
    reg.tm_min = 0;
    reg.tm_sec = 0;
    sw_butt ^= 4;//reset
  }
  if(!stop && (sw_butt&1)==1) sw_tick();
  if(++button_sec == 3) mode = delays[mode];//change mode
  switch(mode) {
  case 0: draw_dp(0b101010, 3);//time
    if (!clock_is_24h_style()) {
      if(tick_time->tm_hour > 11)
        draw(26, 0);//PM
      else
        draw(23, 0);//AM
    }
    tock(tick_time, false, clock_is_24h_style());
    break;
  case 1: draw_dp(0b100, 3);//date
    draw(days[tick_time->tm_mon * 3 + 21], 5);
    draw(days[tick_time->tm_mon * 3 + 22], 6);
    draw(days[tick_time->tm_mon * 3 + 23], 7);
    draw(tick_time->tm_mday/10, 3);
    draw(tick_time->tm_mday%10, 4);
    draw(days[tick_time->tm_wday * 3], 0);
    draw(days[tick_time->tm_wday * 3 + 1], 1);
    draw(days[tick_time->tm_wday * 3 + 2], 2);
    break;
  case 2: draw_dp(0b1010 + (((sw_butt&1)==1)?32:0) + (((sw_butt&2)==2)?0b10001:0), 3);//stopwatch
    if((sw_butt&2)==2) {
      tock(&lap, true, true);
    } else {
      tock(&reg, true, true);
    }
    break;
  case 3: printreal(value, false);
    break;
  case 4: draw_dp(1<<(direction%5), 8);//score
    printint(score, 7, false);
    break;
  case 5: draw_dp(1<<(direction%5), 8);//level
    printint(level, 7, false);
    draw(28, 0);//L
    break;
  case 6: draw_dp(1<<(direction%5), 8);//hiscore
    printint(hiscore, 7, false);
    draw(18, 0);//H
    break;
  default: break;
  }
}
开发者ID:jackokring,项目名称:pebble-sdk-examples,代码行数:53,代码来源:clock.c

示例15:

void
runtime·printslice(Slice a)
{
#line 197 "C:\Users\ADMINI~1\AppData\Local\Temp\2\makerelease686069423\go\src\pkg\runtime\slice.goc"

	runtime·prints("[");
	runtime·printint(a.len);
	runtime·prints("/");
	runtime·printint(a.cap);
	runtime·prints("]");
	runtime·printpointer(a.array);
}
开发者ID:ader1990,项目名称:go,代码行数:12,代码来源:zslice_windows_amd64.c


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