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


C++ Cprintf函数代码示例

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


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

示例1: ws_status_timer

void
ws_status_timer(Timer tm, Name status)
{ UINT id;

  if ( (id = getIdTimer(tm)) )
  { KillTimer(NULL, id);
    deleteHashTable(TimerTable, toInt(id));
    setIdTimer(tm, 0);
  }

  if ( status != NAME_idle )
  { long msec = (long) (valReal(tm->interval) * 1000.0);

    if ( (id = SetTimer(NULL, 0, (UINT)msec, (TIMERPROC) timer_proc)) )
    { if ( !TimerTable )
      { TimerTable = globalObject(CtoName("active_timers"),
				  ClassHashTable, EAV);
	assign(TimerTable, refer, NAME_none);
      }
      appendHashTable(TimerTable, toInt(id), tm);
      setIdTimer(tm, id);
      DEBUG(NAME_timer, Cprintf("Created timer of %d milliseconds (id = %d)\n",
				msec, id));
    } else
      Cprintf("Failed SetTimer()\n");
  }
}
开发者ID:brayc0,项目名称:nlfetdb,代码行数:27,代码来源:mstimer.c

示例2: cmd_exec

static void cmd_exec(int argc, const char * const * argv)
{
#define CMD_EXEC_MAX_ARGS (8)
    int args[CMD_EXEC_MAX_ARGS];
    int fidx;
    int i, exec_res;
    char *eptr;

    if (argc < 1 || argc > CMD_EXEC_MAX_ARGS+1)
	goto syntax_err;

    fidx = csp_vm_find_func(argv[0]);
    if (fidx < 0){
	Cprintf("not found\n");
    }

    for (i=1;i<argc && i<CMD_EXEC_MAX_ARGS+1;i++){
	args[i-1] = strtoul(argv[i], &eptr, 0);
	if (!eptr || *eptr != 0){
	    goto syntax_err;
	}
    }

    exec_res = csp_vm_run_function(1000, fidx, argc-1, args);
    Cprintf("\nexec %s(): %d %d\n", argv[0], exec_res, csp_vm_get_call_result());

    return;

syntax_err:
    Cprintf("Usage: exec <name> [args...]\n");
}
开发者ID:MbedTinkerer,项目名称:STM32USBkeyboard,代码行数:31,代码来源:shell.c

示例3: main

int main()
{
    BOOL	bSuccess;
    int     i;
    char	szBuf[30];

    InitConsoleIO();        // must call this at startup

    ClrScr();              // clear the screen

    for ( i=0; i < 20; i += 2 ) {
		// QUESTION H what does the next line do?
        GotoXY(i,i);   
		// make a message and put it out
        sprintf( szBuf, "%d,%d", i, 2*i );
        bSuccess = PutText(szBuf);  // test PutText.
        if (!bSuccess) 
            printf("WriteConsoleOutputCharacter error\n"); 
    }

	// make some cool messages in different colours
    TextColour( BC_RED );
    TextBackground( BC_GREEN );
    Cprintf("Cool %d ", i++);

    TextColour( BC_BLACK );
    TextBackground( BC_LIGHTGRAY );
    Cprintf("colours %d ", i++);

    TextColour( BC_LIGHTMAGENTA );
    TextBackground( BC_BLUE );
    Cprintf(" Eh %d?", i);

    return(1);
}
开发者ID:acranbury,项目名称:Paging,代码行数:35,代码来源:console.cpp

示例4: colourPixel

static unsigned long
colourPixel(Display *disp, int depth, Colormap cmap,
	    Table t, int r, int g, int b)
{ unsigned long pixel;
  unsigned long direct = (r << 16) + (g << 8) + b;
  XColor c;

  if ( (pixel = memberTable(t, direct)) != NOPIXEL )
    return pixel;

  ncolours++;

  c.red   = r * 257;
  c.green = g * 257;
  c.blue  = b * 257;
  if ( !XAllocColor(disp, cmap, &c) )
  { if ( !allocNearestColour(disp, cmap, depth, DEFAULT, &c) )
    { Cprintf("PNM: failed to alloc pixel %d/%d/%d\n", r, g, b);
      c.pixel = 0;
      nfailed++;
    }
  }

  addTable(t, direct, c.pixel);

  DEBUG(NAME_ppm, Cprintf("PNM: Colour %d %d %d on pixel %d\n",
			  r, g, b, c.pixel));
  return c.pixel;
}
开发者ID:brayc0,项目名称:nlfetdb,代码行数:29,代码来源:xppm.c

示例5: x_error_handler

static int
x_error_handler(Display *display, XErrorEvent *error)
{ if ( !catchedErrorPce(PCE, NAME_xError) )
  { char msg[1024];
    char request[100];
    char buf[100];

					/* XSetInputFocus() can generate a */
					/* BadMatch that is hard to avoid */
    if ( error->request_code == X_SetInputFocus &&
	 error->error_code == BadMatch )
      return 0;

    XGetErrorText(display, error->error_code, msg, 1024);
    sprintf(buf, "%d", error->request_code);
    XGetErrorDatabaseText(display, "XRequest", buf,
			  "Unknown request", request, 100);
    Cprintf("X error of failed request: %s\n", msg);
    Cprintf("Major opcode of failed request: %d (%s)\n",
	    error->request_code, request);
    Cprintf("Minor opcode of failed request: %d\n", error->minor_code);
    Cprintf("Resource id in failed request:  0x%x\n",
	    (unsigned int) error->resourceid);
    Cprintf("Serial number of failed request: %ld\n", error->serial);

    errorPce(NIL, NAME_xError);
  }

  return 0;				/* what to return here? */
}
开发者ID:brayc0,项目名称:nlfetdb,代码行数:30,代码来源:xcommon.c

示例6: parse_font

static status
parse_font(char *s, LOGFONT *lfont)
{ while(*s)
  { char att[100];
    int n = -1;
    char *q;

    for(q=att; isalpha(*s); *q++ = *s++)
      ;
    *q = EOS;

    if ( stricmp(att, "height") == 0 )
      n=long_attribute(s, &lfont->lfHeight);
    else if ( stricmp(att, "width") == 0 )
      n=long_attribute(s, &lfont->lfWidth);
    else if ( stricmp(att, "escapement") == 0 )
      n=long_attribute(s, &lfont->lfEscapement);
    else if ( stricmp(att, "orientation") == 0 )
      n=long_attribute(s, &lfont->lfOrientation);
    else if ( stricmp(att, "weight") == 0 )
      n=long_attribute(s, &lfont->lfWeight);
    else if ( stricmp(att, "italic") == 0 )
      n=bool_attribute(s, &lfont->lfItalic);
    else if ( stricmp(att, "underline") == 0 )
      n=bool_attribute(s, &lfont->lfUnderline);
    else if ( stricmp(att, "strikeout") == 0 )
      n=bool_attribute(s, &lfont->lfStrikeOut);
    else if ( stricmp(att, "charset") == 0 )
      n=named_attribute(s, charset_names, 0xff, &lfont->lfCharSet);
    else if ( stricmp(att, "outprecision") == 0 )
      n=named_attribute(s, outprecision_names, 0xff, &lfont->lfOutPrecision);
    else if ( stricmp(att, "clipprecision") == 0 )
      n=named_attribute(s, clipprecision_names, 0xff, &lfont->lfClipPrecision);
    else if ( stricmp(att, "quality") == 0 )
      n=named_attribute(s, quality_names, 0xff, &lfont->lfQuality);
    else if ( stricmp(att, "pitch") == 0 )
      n=named_attribute(s, pitch_names, 0x3, &lfont->lfPitchAndFamily);
    else if ( stricmp(att, "family") == 0 )
      n=named_attribute(s, family_names, 0xf8, &lfont->lfPitchAndFamily);
    else if ( stricmp(att, "face") == 0 )
      n=string_attribute(s, lfont->lfFaceName, LF_FACESIZE);
    else
      Cprintf("Bad font-attribute name: %s\n", att);

    if ( n < 0 )
    { Cprintf("Bad value for font-attribute %s\n", att);
      while( *s && *s != ':' )
	s++;
    } else
    { DEBUG(NAME_font, Cprintf("att %s: read %d chars\n", att, n));
      s += n;
      if ( *s == ':' )
	s++;
    }
  }

  succeed;
}
开发者ID:brayc0,项目名称:nlfetdb,代码行数:58,代码来源:msfont.c

示例7: ws_create_window

status
ws_create_window(PceWindow sw, PceWindow parent)
{ Widget w;
  DisplayObj d = getDisplayGraphical((Graphical)sw);

					/* create the widget */
  { Arg args[8];
    Cardinal n = 0;
    int pen = valInt(sw->pen);

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Actually, it appears Xt is ignoring the geometry parameters.  Hence,
ws_realise_frame() sends ->geometry to all windows.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

    XtSetArg(args[n], XtNx,	      valInt(sw->area->x)); n++;
    XtSetArg(args[n], XtNy,	      valInt(sw->area->y)); n++;
    XtSetArg(args[n], XtNwidth,       valInt(sw->area->w) - 2*pen); n++;
    XtSetArg(args[n], XtNheight,      valInt(sw->area->h) - 2*pen); n++;
    XtSetArg(args[n], XtNborderWidth, pen); n++;
    XtSetArg(args[n], XtNinput,       True); n++;
    if ( instanceOfObject(sw->background, ClassColour) )
    { XtSetArg(args[n], XtNbackground, getPixelColour(sw->background, d));
      n++;
    } else
    { Pixmap pm = (Pixmap) getXrefObject(sw->background, d);

      XtSetArg(args[n], XtNbackgroundPixmap, pm); n++;
    }

    DEBUG(NAME_create, Cprintf("Calling XtCreateWidget ..."));
    w = XtCreateWidget(strName(sw->name),
		       canvasWidgetClass,
		       isDefault(parent) ? widgetFrame(sw->frame)
					 : widgetWindow(parent),
		       args, n);
    DEBUG(NAME_create, Cprintf("Widget = %p\n", w));
  }

  if ( !w )
    return errorPce(w, NAME_createFailed);

  setWidgetWindow(sw, w);

  XtAddCallback(w, XtNeventCallback,   event_window, sw);
  XtAddCallback(w, XtNexposeCallback,  expose_window, sw);
  XtAddCallback(w, XtNresizeCallback,  resize_window, sw);
  XtAddCallback(w, XtNdestroyCallback, destroy_window, sw);

  if ( notDefault(parent) )		/* make a sub-window */
  { XtManageChild(w);
    send(sw, NAME_displayed, ON, EAV);
  }

  succeed;
}
开发者ID:SWI-Prolog,项目名称:packages-xpce,代码行数:56,代码来源:xwindow.c

示例8: Wait

void Wait ()   /* Busy-wait for a key from keyboard */
{
  int flag;

  Cprintf ("Press any key to continue... ") ;
  flag = Mod_int (INT_ENABLE);
  while( Get_char() == NULL ) ;
  Mod_int (flag);
  Cprintf ("\n") ;
}
开发者ID:rjrpaz,项目名称:os-implementation,代码行数:10,代码来源:test6.c

示例9: test3a_Q

/** Aux function **/
int test3a_Q( int argc, char** argv )
{
  if( argv[0][0] != 'M' ) {
    Cprintf( "%s.q ", argv[0] );
  }
  else {
    Cprintf( "notes to " );
  }
  return 0;
}
开发者ID:rjrpaz,项目名称:os-implementation,代码行数:11,代码来源:test3a.c

示例10: Proc

int Proc( int argc, char** argv )
{
  PROCPTR p;
  int     pid;
  char    c;
  
  Cprintf( "test1i:   Hello!\n" );
  Cprintf( "test1i: [Loading test1a...]\n" );

  p = Load_module( "test1a.mod" );

  Cprintf( "test1i:   proc == %p\n", p );
  Cprintf( "test1i: [Starting test1a...]\n" );

  pid = Proc_start( p, child_argc, child_argv );

  Cprintf( "test1i:   pid == %d\n", pid );
  Cprintf( "test1i: [Closing test1a...]\n" );

  Close_module( "test1a.mod" );

  Cprintf( "test1i: [Sleeping until keypress...]\n" );

  c = Get_char();

  Cprintf( "test1i:   c == '%c'\n", c );
  Cprintf( "test1i: [Terminating...]\n" );

  return 0;
}
开发者ID:rjrpaz,项目名称:os-implementation,代码行数:30,代码来源:test1i.c

示例11: cmd_help

static void cmd_help(int argc, const char * const * argv)
{
    const struct shell_command *cmd;
    int i;

    Cprintf("Commands:\n");
    for (i=0;i<shell_commands_count;i++){
	cmd = &shell_commands[i];
	Cprintf("    %-16s - %s\n", cmd->name, cmd->descr);
    }
}
开发者ID:MbedTinkerer,项目名称:STM32USBkeyboard,代码行数:11,代码来源:shell.c

示例12: ws_discard_input

void
ws_discard_input(const char *msg)
{ if ( dispatch_fd >= 0 && input_on_fd(dispatch_fd) )
  { char buf[1024];

    Cprintf("%s; discarding input ...", msg);
    if ( read(dispatch_fd, buf, sizeof(buf)) >= 0 )
      Cprintf("ok\n");
    else
      Cprintf("failed\n");
  }
}
开发者ID:SWI-Prolog,项目名称:packages-xpce,代码行数:12,代码来源:xevent.c

示例13: cmd_load

static void cmd_load(int argc, const char * const * argv)
{
    if (argc != 0)
	goto syntax_err;

    Cprintf("Expecting script code.\nEnd with a Ctrl+D (ASCII char code 4).\n");

    load_script_from_console();

    return;

syntax_err:
    Cprintf("Usage: load\n");
}
开发者ID:MbedTinkerer,项目名称:STM32USBkeyboard,代码行数:14,代码来源:shell.c

示例14: ws_provide_selection

int
ws_provide_selection(int format)
{ DisplayObj d = CurrentDisplay(NIL);
  Hyper h;
  Function msg;
  Name which     = NAME_primary;
  Name hypername = getAppendName(which, NAME_selectionOwner);
  Name type;

  if ( d && notNil(d) &&
       (h    = getFindHyperObject(d, hypername, DEFAULT)) &&
       (type = getAttributeObject(h, NAME_type)) &&
       (msg  = getAttributeObject(h, NAME_convertFunction)) &&
       (msg  = checkType(msg, TypeFunction, NIL)) )
  { Any val;

    DEBUG(NAME_selection, Cprintf("Provide %s selection of type %s\n",
				  pp(which), pp(type)));

    if ( !(val = getForwardReceiverFunction(msg, h->to, which, type, EAV)) )
      return FALSE;

    DEBUG(NAME_selection, Cprintf("Got %s\n", pp(val)));

    if ( type == NAME_text )
    { CharArray ca = checkType(val, TypeCharArray, NIL);

      if ( ca )
      { String s = &ca->data;
      	HGLOBAL mem = ws_string_to_global_mem(s);

	if ( mem )
	  SetClipboardData(CF_UNICODETEXT, mem);

	return TRUE;
      }
    } else if ( type == NAME_emf || type == NAME_wmf )
    { Any mf = checkType(val, nameToType(NAME_winMetafile), NIL);

      if ( mf )
      { DEBUG(NAME_selection, Cprintf("Providing win_metafile\n"));
	return ws_on_clipboard_metafile(mf, type);
      }
    } else
      return errorPce(d, NAME_noSelectionType, type);
  }

  return FALSE;
}
开发者ID:SWI-Prolog,项目名称:packages-xpce,代码行数:49,代码来源:msdisplay.c

示例15: main

int
main(int argc, char* argv[])
{ if ( !pceInitialise(0, NULL, argc, argv) )
  { Cprintf("Sorry, failed to initialise XPCE\n");
    exit(1);
  }

  if ( !pceInitApplication(argc, argv) )
  { Cprintf("Failed to run pceInitApplication()\n");
    exit(1);
  }

  for(;;)
    pceDispatch(0, 1000);
}
开发者ID:SWI-Prolog,项目名称:packages-xpce,代码行数:15,代码来源:main.c


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