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

C++ readint函数代码示例

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

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



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

示例1: msglist

int msglist (void)
{
	int x;
	if (server) {
		x = writemsg (MSGLIST);
		if (x == SCMOK)  x = Tprocess (listT,listone);
		if (x == SCMOK)  x = writestring ((char *)NULL);
		if (x == SCMOK)  x = writeint ((int)scantime);
		if (x == SCMOK)  x = writemend ();
	} else {
		char *name;
		int mode,flags,mtime;
		TREE *t;
		x = readmsg (MSGLIST);
		if (x == SCMOK)  x = readstring (&name);
		while (x == SCMOK) {
			if (name == NULL)  break;
			x = readint (&mode);
			if (x == SCMOK)  x = readint (&flags);
			if (x == SCMOK)  x = readint (&mtime);
			if (x != SCMOK)  break;
			t = Tinsert (&listT,name,TRUE);
			free (name);
			t->Tmode = mode;
			t->Tflags = flags;
			t->Tmtime = mtime;
			x = readstring (&name);
		}
		if (x == SCMOK)  x = readint ((int *)&scantime);
		if (x == SCMOK)  x = readmend ();
	}
	return (x);
}
开发者ID:andreiw,项目名称:ode4linux,代码行数:33,代码来源:supmsg.c


示例2: handle_request

void handle_request(void) {
  void *allocs[100] = {0};
  uint32_t alloc_idx;

  sendstr(" **** WELCOME TO THE HEAP SIMULATOR 2001! ****\n\n");
  while (1) {
    sendstr("What would you like to do?\n");
    sendstr(" 1) Allocate memory\n");
    sendstr(" 2) Free memory\n");
    sendstr(" 3) Read some data\n");
    sendstr(" 4) Exit\n\n");

    int cmd = readint();
    uint16_t id;
    switch (cmd) {
        case 1:
            for (alloc_idx = 0; alloc_idx < sizeof(allocs) && allocs[alloc_idx] != NULL; ++alloc_idx) ;

            if (alloc_idx >= sizeof(allocs)) {
                sendstr("Run out of space, free something first!\n");
            } else {
                sendstr("Ok, how much memory do you want (in bytes)?\n");
                uint16_t bytes = readint();
                allocs[alloc_idx] = (void *)alloc(bytes);
                sendstr(tprintf("Allocated with ID = %d\n", alloc_idx));
            }
            dump_heap();
            break;
        case 2:
            sendstr("Please enter the ID of the alloc to free\n");
            id = readint();
            if (id < sizeof(allocs) && allocs[id] != NULL) {
                dealloc(allocs[id]);
                allocs[id] = NULL;
            } else {
                sendstr("Alloc not found\n");
            }
            dump_heap();
            break;
        case 3:
            sendstr("Please enter the ID of the alloc where to read data\n");
            id = readint();
            if (id < sizeof(allocs) && allocs[id] != NULL) {
                sendstr("Ready! Send the data\n");
                recvline(client_fd, allocs[id], 0x100);
            } else {
                sendstr("Alloc not found\n");
            }
            dump_heap();
            break;
        case 4:
            say_bye();
            exit(0);
            break;
        default:
            sendstr("What!?\n");
    };
  }

}
开发者ID:NUSGreyhats,项目名称:xctf-2016-quals-challenges,代码行数:60,代码来源:heap_simulator2001.c


示例3: main

int main() {
    for (; scanf("%d%d",&n,&m) != EOF;) {
        totg = n;
        tn = (n*3)/4;
        for (i = 0; i <= n; i++)  g[i].next = -1;
        for (i = 1; i <= n; i++)  addedge(0,i,-1);
        for (i = 1; i <= m; i++) {
            x = readint();
            y = readint();
            z = readint();
            if (x == 1) {
                addedge(y,z,0);
                addedge(z,y,0);
            }
            else if (x == 2)addedge(y,z,-1);
            else if (x == 3)addedge(z,y,0);
            else if (x == 4)addedge(z,y,-1);
            else addedge(y,z,0);
        }
        hasres = SPFA();
        if (hasres == 1) {
            res = 0;
            for (i = 1; i <= n; i++)res += (long long)(-d[i]);
            printf("%lld\n",res);
        }
        else printf("-1\n");
    }
}
开发者ID:mzry1992,项目名称:workspace,代码行数:28,代码来源:糖果.c


示例4: comment_add

void comment_add(char **comments, int* length, char *tag, char *val)
{
    char* p=*comments;
    int vendor_length=readint(p, 8);
    int user_comment_list_length=readint(p, 8+4+vendor_length);
    int tag_len=(tag?strlen(tag)+1:0);
    int val_len=strlen(val);
    int len=(*length)+4+tag_len+val_len;

    p=(char*)realloc(p, len);
    if(p==NULL){
        fprintf(stderr, "realloc failed in comment_add()\n");
        exit(1);
    }

    writeint(p, *length, tag_len+val_len);      /* length of comment */
    if(tag){
        memcpy(p+*length+4, tag, tag_len);        /* comment tag */
        (p+*length+4)[tag_len-1] = '=';           /* separator */
    }
    memcpy(p+*length+4+tag_len, val, val_len);  /* comment */
    writeint(p, 8+4+vendor_length, user_comment_list_length+1);
    *comments=p;
    *length=len;
}
开发者ID:iulianu,项目名称:oreka,代码行数:25,代码来源:OggOpusFile.cpp


示例5: main

/** @brief Programa principal para la practica de PRO2: 'Red ferroviaria'. */
int main() {

  // Leer cuantas cocheras
  int M = readint();
  // Inicializar la red, las cocheras y los trenes
  Red red;

  red.leer_red();
  Cjt_Cocheras cocheras(M);
  cocheras.leer_cocheras();

  Cjt_Trenes trenes;
  trenes.leer_trenes();
  // Procesar las opciones
  int opcion = readint();

  while (opcion != -6) {
    if (opcion == -1) cocheras.almacenamiento_nocturno(red, trenes);

    else if (opcion == -2) cocheras.formacion_matinal(trenes);

    else if (opcion == -3) trenes.leer_tren();
    else if (opcion == -4) cocheras.leer_cocheras();

    else if (opcion == -5) cocheras.escribir_cocheras();
    opcion = readint();
  }

  return 0;
}
开发者ID:llop,项目名称:practica-pro2-red-ferroviaria,代码行数:31,代码来源:pro2.cpp


示例6: readint

void Servidor::actualizar_pelicula(){
  int x;
  x = readint();
  addPeliculas(x);
  x = readint();
  deletePeliculas(x);
}
开发者ID:alexperegrina,项目名称:mega-pro2-load,代码行数:7,代码来源:Servidor.cpp


示例7: main

int main(void) {
    int c, lim, s, t;
    int *n, *p;
    for(readint(t); t--; ) {
        readint(s);
        readint(c);
        for(int i = 0; i < s; ++i) readint(d[0][i]);
        for(lim = s; lim--; ) {
            bool change = false;
            n = d[s - lim];
            p = d[s - lim - 1];
            for(int i = 0; i < lim; ++i) {
                n[i] = p[i + 1] - p[i];
                change |= i && n[i] != n[i - 1];
            }
            if(!change) {
                for(int i = lim; i < lim + c; ++i) n[i] = n[0];
                break;
            }
        }
        while(lim++ < s) {
            n = d[s - lim];
            p = d[s - lim + 1]      ;
            for(int i = lim; i < lim + c; ++i) n[i] = n[i - 1] + p[i - 1];
        }
        if(s > 1) for(int i = s; i < s + c; ++i) buffer(n[i], i==s+c-1?10:32);
        else for(int i = 0; i < c; ++i) buffer(d[0][0], i==c-1?10:32);
    }
    flush_buffer();
    return 0;
}
开发者ID:a5216652166,项目名称:coding,代码行数:31,代码来源:CMPLS.cpp


示例8: readint

/**
 * Constructor
 * @param ss substream to read from
 */
hpiutil::sqshstream::sqshstream(substream &ss)
{
	valid = false;
	stream = &ss;
	boost::uint32_t magic = readint();
	if (magic != SQSH_MAGIC) {
		std::cerr << "Invalid SQSH header signature: 0x" << std::hex << magic << std::endl;
		return;
	}
	boost::uint8_t unknown = stream->read();
	compress = stream->read();
	encrypt = stream->read();
	compressedsize = readint();
	fullsize = readint();
	checksum = readint();
	boost::uint32_t newcheck = stream->checksum(SQSH_HEADER);
	if (checksum && (newcheck != checksum)) {
		std::cerr << "Chunk checksum " << std::hex << newcheck << " does not match stored checksum " << std::hex << checksum << std::endl;
		return;
	}
	if (decompress())
		valid = true;
	else
		free((void*)data);
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:29,代码来源:sqshstream.cpp


示例9: readint2

static int readint2( const char** source, int* x, int* y )
{
  if ( readint( source, x ) != 0 )
  {
    return -1;
  }

  return readint( source, y );
}
开发者ID:leiradel,项目名称:retroluxury,代码行数:9,代码来源:rl_bdffont.c


示例10: print_comments

static void print_comments(char *comments, int length)
{
   char *c=comments;
   int len, i, nb_fields, err=0;

   if (length<(8+4+4))
   {
      fprintf (stderr, "Invalid/corrupted comments\n");
      return;
   }
   if (strncmp(c, "OpusTags", 8) != 0)
   {
      fprintf (stderr, "Invalid/corrupted comments\n");
      return;
   }
   c += 8;
   fprintf(stderr, "Encoded with ");
   len=readint(c, 0);
   c+=4;
   if (len < 0 || len>(length-16))
   {
      fprintf (stderr, "Invalid/corrupted comments\n");
      return;
   }
   err&=fwrite(c, 1, len, stderr)!=(unsigned)len;
   c+=len;
   fprintf (stderr, "\n");
   /*The -16 check above makes sure we can read this.*/
   nb_fields=readint(c, 0);
   c+=4;
   length-=16+len;
   if (nb_fields < 0 || nb_fields>(length>>2))
   {
      fprintf (stderr, "Invalid/corrupted comments\n");
      return;
   }
   for (i=0;i<nb_fields;i++)
   {
      if (length<4)
      {
         fprintf (stderr, "Invalid/corrupted comments\n");
         return;
      }
      len=readint(c, 0);
      c+=4;
      length-=4;
      if (len < 0 || len>length)
      {
         fprintf (stderr, "Invalid/corrupted comments\n");
         return;
      }
      err&=fwrite(c, 1, len, stderr)!=(unsigned)len;
      c+=len;
      length-=len;
      fprintf (stderr, "\n");
   }
}
开发者ID:SmarterApp,项目名称:SB_MobileSecureBrowser-iOS,代码行数:57,代码来源:opusdec.c


示例11: main

int main(void) {
    int a, b, t;
    readint(&t);
    for(int cnum = 0; cnum++ < t; ) {
        readint(&a);
        readint(&b);
        printf("Case %d: %d\n", cnum, (a + b)/gcd(a, b));
    }
    return 0;
}
开发者ID:a5216652166,项目名称:coding,代码行数:10,代码来源:11774.cpp


示例12: readFArr1D

void readFArr1D(ifstream& stream, FArr1D& v)
{
  int Lo1, Hi1;
  char s[4];
  readint(stream, Lo1);
  readint(stream, Hi1);
  assert( v.L1() == Lo1 && v.H1() == Hi1 );  // Check lim match.
  for(int i=Lo1; i<=Hi1; i++) stream >> v(i);
  stream.getline(s, 4);
//  stream.ignore(80, '\n');
};
开发者ID:dunghand,项目名称:msrds,代码行数:11,代码来源:uIO.cpp


示例13: readint

/** @brief Se leen los trenes para la formacion matinal del canal estandar de entrada.
 *  \pre cierto
 *  \post Retorna una lista con los trenes.
 */
list<Tren> Cjt_Cocheras::get_trenes_formacion_matinal(Cjt_Trenes &trenes) const {

  list<Tren> trenes_formacion;
  int num_trenes = readint();

  for (int i = 0; i < num_trenes; i++) {

    int id_tren = readint();
    Tren tren = trenes.get_tren(id_tren);

    trenes_formacion.insert(trenes_formacion.end(), tren);
  }
  return trenes_formacion;
}
开发者ID:llop,项目名称:practica-pro2-red-ferroviaria,代码行数:18,代码来源:Cjt_Cocheras.cpp


示例14: main

/* }}} end FAST integer input */
int main(void){
	int t; readint(t);
	for(int cnum = 0, n; cnum++ < t; ){
		readint(n);
		int cs = 0, ms = 0;
		for(int i = 0, p = 0, z; i++ < n; p = z){
			readint(z);
			int dist = z - p;
			if(cs == dist) --cs;
			else if(cs < dist) cs = dist > ms ? (ms = dist) - 1 : ++ms;
		}
		printf("Case %d: %d\n", cnum, ms);
	}
	return 0;
}
开发者ID:a5216652166,项目名称:coding,代码行数:16,代码来源:12032.cpp


示例15: main_nodisplay

void main_nodisplay() {
  float x, y, z = 0;
  
  // main loop  
   while(1) 
  {  
    led1=led2=led3=led4=0;
    mnu->SetScreen("Wait for file ...");
    while (srv->State() == listen)
        Net::poll();
    GetFile();
    mot->reset();
    plan_get_current_position_xyz(&x, &y, &z);
     printf("%f %f\n", x,y); 
    mnu->SetScreen("Laser BUSY..."); 
    
    char name[32];
    srv->getFilename(name);
    printf("Now processing file: '%s'\n\r", name);
    FILE *in = sd.openfile(name, "r");
    while (!feof(in))
    { 
      while (!mot->ready() );
      mot->write(readint(in));
    }
    fclose(in);
    removefile(name);
    // done
    printf("DONE!...\n");
	while (!mot->ready() );
    mot->moveTo(cfg->xrest, cfg->yrest, cfg->zrest);
  }
}
开发者ID:garychan,项目名称:Firmware,代码行数:33,代码来源:main.cpp


示例16: main

int main() {
	int n;
	n = readint("Please input an integer: ");
	print("Your input number is: %d", n);

	return 0;
}
开发者ID:pandolia,项目名称:tinyc,代码行数:7,代码来源:sample_1_io.c


示例17: emitT

void
emitT(int t)
{
	int i, j, k;

	printf("\n");
	printf("static int T%d[] = {\n", t);

	for (i=k=0; i<maxlen; i++) {
		for (j=0; j<256; j++) {
			int v = readint();
			if (compact && (j < minchar || j > maxchar))
				continue;
			if (k == 0)
				printf("\t");
			printf("%d,", v);
			if (++k == 10) {
				printf("\n");
				k = 0;
			}
			else
				printf(" ");
		}
	}
	if (k)
		printf("\n");
	printf("};\n");
}
开发者ID:Dergash,项目名称:homm3tools,代码行数:28,代码来源:emitc.c


示例18: main

int main()
{
    char line[MAXL];
    int i;

    eofread = FALSE;

    readint( &ndw );

    for ( i = 0; i < ndw; i++ )
    {
        dlengths[i] = getline( dictionary[i] );
    }

    while ( ( nic = getline( line ) ) != FAIL )
    {
        niw = split( line );

        init();

        if ( backtrack( 0 ) )
            process( line );
        else
            failed( line );
    }

    return 0;
}
开发者ID:roblapp,项目名称:uva_online_judge,代码行数:28,代码来源:main.c


示例19: msgxpatch

int msgxpatch (void)
{
	int x;
	int i;

	if (server) {
		x = readmsg (MSGXPATCH);
		if (x != SCMOK)  return (x);
		x = readint (&xargc);
		if (x != SCMOK)  return (x);
		xargc += 2;
		xargv = (char **)calloc (sizeof (char *),(unsigned)xargc+1);
		if (xargv == NULL)
			return (SCMERR);
		for (i = 2; i < xargc; i++) {
			x = readstring (&xargv[i]);
			if (x != SCMOK)  return (x);
		}
		x = readmend ();
	} else {
		x = writemsg (MSGXPATCH);
		if (x != SCMOK)  return (x);
		x = writeint (xargc);
		if (x != SCMOK)  return (x);
		for (i = 0; i < xargc; i++) {
			x = writestring (xargv[i]);
			if (x != SCMOK)  return (x);
		}
		x = writemend ();
	}
	return (x);
}
开发者ID:andreiw,项目名称:ode4linux,代码行数:32,代码来源:supmsg.c


示例20: msgneed

int msgneed (void)
{
	int x;
	if (server) {
		char *name;
		int update;
		TREE *t;
		x = readmsg (MSGNEED);
		if (x == SCMOK)  x = readstring (&name);
		while (x == SCMOK) {
			if (name == NULL)  break;
			x = readint (&update);
			if (x != SCMOK)  break;
			t = Tinsert (&needT,name,TRUE);
			free (name);
			if (update)  t->Tflags |= FUPDATE;
			x = readstring (&name);
		}
		if (x == SCMOK)  x = readmend ();
	} else {
		x = writemsg (MSGNEED);
		if (x == SCMOK)  x = Tprocess (needT,needone);
		if (x == SCMOK)  x = writestring ((char *)NULL);
		if (x == SCMOK)  x = writemend ();
	}
	return (x);
}
开发者ID:andreiw,项目名称:ode4linux,代码行数:27,代码来源:supmsg.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ readl函数代码示例发布时间:2022-05-30
下一篇:
C++ readinputportbytag函数代码示例发布时间: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