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

C++ readi函数代码示例

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

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



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

示例1: main

int main()
{
    int arr[20];
    int i, n, ep;

    prints("Enter the number of integers n: ");
    n = readi(&ep);
    prints("You entered n = ");
    printi(n);
    prints("\n");

    prints("Enter n integers: ");
    for(i=0; i<n; i++) arr[i] = readi(&ep);
    sort(arr,n);

    prints("The n integers in ascending order: ");
    for(i=0; i<n; i++)
    {
        printi(arr[i]);
        prints(" ");
    }
    prints("\n");

    return 0;
}
开发者ID:biswajitsc,项目名称:tinyC-compiler,代码行数:25,代码来源:ass6_12CS30009_test5.c


示例2: main

int main(){
  int mat[100][100];
  char *c="\nPlease Enter Dimension of matrixr: ";
  char *d="\nPlease Enter the matrix row-wise: ";
  char *e="\nThe Entered matrix is: ";
  char *f="\nThe Transposed matrix is: ";
  char *sp=" ";
  char *ne="\n";
  prints(c);
  int err,n,i,j,k;
  n = readi(&err);
  int temp;
  prints(d);
  for (i = 0; i < n; ++i)
  {
    for (j = 0; j < n; ++j)
    {
      mat[i][j]=readi(&err);
    }
  }
  prints(e);
  prints(ne);
  for (i = 0; i < n; ++i)
  {
    prints(ne);
    for (j = 0; j < n; ++j)
    {
      printi(mat[i][j]);
      prints(sp);
    }
  }
  prints(f);
  prints(ne);

  for (i = 0; i < n; ++i)
  {
    for (j = i+1; j < n; ++j)
    {
      temp=mat[j][i];
      mat[j][i]=mat[i][j];
      mat[i][j]=temp;
    }
    
  }
  for (i = 0; i < n; ++i)
  {
    prints(ne);
    for (j = 0; j < n; ++j)
    {
      printi(mat[i][j]);
      prints(sp);
    }
  }
  prints(ne);
return 0;
}
开发者ID:ma08,项目名称:tinyc,代码行数:56,代码来源:ass4_12CS30035_test4.c


示例3: main

/* Driver program to test above function */
int main()
{
  int arr[50], n, i, err;
  prints("Longest Increasing Subsequence\n");
  prints("Enter number of elements ( < 50)\n");
  n = readi(&err);
  prints("Enter array elements\n");
  for(i = 0; i < n; i++) arr[i] = readi(&err);
  prints("Length of LIS is "); printi(lis( arr, n ) ); prints("\n");
  return 0;
}
开发者ID:anuraganand,项目名称:TinyC-compiler,代码行数:12,代码来源:ass6_12CS30006_test4.c


示例4: dirlink

// Write a new directory entry (name, inum) into the directory dp.
int
dirlink(struct inode *dp, char *name, uint inum)
{
  int off;
  struct dirent de;
  struct inode *ip;

  // Check that name is not present.
  if((ip = dirlookup(dp, name, 0)) != 0){
    iput(ip);
    return -1;
  }

  // Look for an empty dirent.
  for(off = 0; off < dp->size; off += sizeof(de)){
    if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
      panic("dirlink read");
    if(de.inum == 0)
      break;
  }

  strncpy(de.name, name, DIRSIZ);
  de.inum = inum;
  if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
    panic("dirlink");
  
  return 0;
}
开发者ID:gaohannk,项目名称:xv6-system,代码行数:29,代码来源:fs.c


示例5: loaduvm

// Load a program segment into pgdir.  addr must be page-aligned
// and the pages from addr to addr+sz must already be mapped.
int
//20160313--
loaduvm(pde_t *pgdir, char *addr, struct inode *ip, uint offset, uint sz)
//loaduvm(pde_t *pgdir, char *addr, uint offset, uint sz)
{
//20160313--
  uint i, pa, n;
  pte_t *pte;

  if((uint) addr % PGSIZE != 0)
    panic("loaduvm: addr must be page aligned");
  for(i = 0; i < sz; i += PGSIZE){
    if((pte = walkpgdir(pgdir, addr+i, 0)) == 0)
      panic("loaduvm: address should exist");
//20160313--
    pa = PTE_ADDR(*pte);
//20160313--
    if(sz - i < PGSIZE)
      n = sz - i;
    else
      n = PGSIZE;
//20160313--
    if(readi(ip, p2v(pa), offset+i, n) != n)
      return -1;
  }
  return 0;
}
开发者ID:ismaellc,项目名称:SOTR,代码行数:29,代码来源:vm.c


示例6: loaduvm

// Load a program segment into pgdir.  addr must be page-aligned
// and the pages from addr to addr+sz must already be mapped.
int loaduvm (pgd_t *pgdir, char *addr, struct inode *ip, uint offset, uint sz)
{
    uint i, pa, n;
    pte_t *pte;

    if ((uint64) addr % PTE_SZ != 0) {
        panic("loaduvm: addr must be page aligned");
    }

    for (i = 0; i < sz; i += PTE_SZ) {
        if ((pte = walkpgdir(pgdir, addr + i, 0)) == 0) {
            panic("loaduvm: address should exist");
        }

        pa = PTE_ADDR(*pte);

        if (sz - i < PTE_SZ) {
            n = sz - i;
        } else {
            n = PTE_SZ;
        }

        if (readi(ip, p2v(pa), offset + i, n) != n) {
            return -1;
        }
    }

    return 0;
}
开发者ID:finallyjustice,项目名称:xv6-OS-for-arm-v8,代码行数:31,代码来源:vm.c


示例7: main

int main()
{
    int a,b;
    int *e;
    
    prints("***********************Some random outputs!!*************************\n");
    
    b = 3;
    e = &b;

    prints("Passing pointers to function f!\n");
    prints("Value passed to function: ");
    printi(b);
    prints("\n");
    a = f(e);
    prints("Value returned from function s is: ");
    printi(a);
    prints("\n");
    
    prints("Read an integer!!");
    prints("\n");
    b = readi(e);
    prints("The integer that was read is:");
    printi(b);
    prints("\n");
    
    return 0;
}
开发者ID:aishikchakraborty,项目名称:TinyC-Compiler,代码行数:28,代码来源:ass6_13CS30041_test1.c


示例8: main

//A test file to test the library functions written
int main()
{
    int n,err=0;
    prints("Write the integer n:");
    n = readi(&err);
    if(err!=ERR)
    {
        prints("The integer read is : ");
        printi(n);
    }
    else
    {
        prints("Wrong Input\n");
    }
    float x;

    prints("\nEnter the decimal number: ");
    err = readf(&x);
    if(err==OK)
    {
        prints("The floating number is :");
        printd(x);
    }
    else
    {
        prints("Wrong Input\n");
    }
    prints("\n");
    return 0;
}
开发者ID:nishkarsh-shastri,项目名称:Compilers_assignments_2014,代码行数:31,代码来源:mainFile.c


示例9: dirlink

int dirlink(struct inode *dp, char *dirname, uint32_t ino)
{
    if(!ISDIR(dp->mode) || ino < 1) {
        return -1;
    }
    
    if(dirlookup(dp, dirname, 0)) 
        return -1;

    struct dirent dir;
    int off;
    for(off = 0; off < dp->size; off+=sizeof(struct dirent))
    {
        if(!readi(dp, (char *)&dir, off, sizeof(struct dirent))) {
            return -1;
        }
        // found a new entry
        if(!dir.ino)
            break;
    }
    
    dir.ino = ino;
    strcpy(dir.name, dirname);
    writei(dp, (char *)&dir, off, sizeof(struct dirent));
    return 0;
}
开发者ID:Turingwy,项目名称:turinux,代码行数:26,代码来源:dirent.c


示例10: dirlookup

// Look for a directory entry in a directory.
// If found, set *poff to byte offset of entry.
struct inode*
dirlookup(struct inode *dp, char *name, uint *poff)
{
  uint off, inum;
  struct dirent de;

  if(dp->type != T_DIR)
    panic("dirlookup not DIR");

  for(off = 0; off < dp->size; off += sizeof(de)){
    if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
      panic("dirlink read");
    if(de.inum == 0)
      continue;
    if(namecmp(name, de.name) == 0){
      // entry matches path element
      if(poff)
        *poff = off;
      inum = de.inum;
      return iget(dp->dev, inum);
    }
  }

  return 0;
}
开发者ID:gaohannk,项目名称:xv6-system,代码行数:27,代码来源:fs.c


示例11: fileread

// Read from file f.
int
fileread(struct file *f, char *addr, int n) {
	int r;

	if (f->readable == 0) {
		return -1;
	}

	if (f->type == FD_PIPE) {
		return piperead(f->pipe, addr, n);
	}

	if (f->type == FD_INODE) {
		ilock(f->ip);

		if ((r = readi(f->ip, addr, f->off, n)) > 0) {
			f->off += r;
		}

		iunlock(f->ip);
		return r;
	}

	panic("fileread");
}
开发者ID:Tachibana-General-Laboratories,项目名称:lainos-fail,代码行数:26,代码来源:file.c


示例12: log_initialize

void
log_initialize()
{
  struct inode *ip;
  uchar buffer[512];
  int i, j;
  struct buf *bp;
  struct trans_start t_blk;

  for(j=0;j<512;j++)
    buffer[j] = 0;

  ip = iget(1, 3);
  ilock(ip);
  if(ip->size < 512*20){
    cprintf("Creating Journal...\n");
    for(i=0;i<20;i++){
      writei(ip, buffer, i*512, sizeof(buffer));
    }
  }
  else {
    readi(ip, &t_blk, 0, sizeof(t_blk));

    if(t_blk.state == LOGGING){
      cprintf("Inconsistency found in file system. Attempting to recover.\n");

      for(i = 0; i < t_blk.num_blks; i++){
    	  readi(ip, buffer, i*512+512, sizeof(buffer));
    	  bp = bread(1, t_blk.sector[i]);
    	  cprintf("Recovering data in sector: %d\n", t_blk.sector[i]);
    	  memmove(bp->data, buffer, sizeof(buffer));
    	  bwrite(bp);
    	  brelse(bp);
      }

      writei(ip, buffer, 0, sizeof(buffer));
      cprintf("Recovery Complete.\n");
    }
  }

  iunlock(ip);
}
开发者ID:fenster,项目名称:xv6-staus-treffert,代码行数:42,代码来源:logfs.c


示例13: main

int main(){
	int n1,result;int *ep;int temp;
	prints("Program to calculate factorial of a number:\n");
	prints("Enter n1:");
	n1=readi();
	result=factorial(n1);
	prints("The factorial of the given number is:");
	printi(result);
	prints("\n");
	return 0;
}
开发者ID:shubhamsaxena02,项目名称:compiler-assignments,代码行数:11,代码来源:ass6_12CS30032_test_5.c


示例14: j_init

void
j_init()
{
  struct inode *ip;
  uchar buffer[512];
  int i, j;
  struct buf *bp;
  struct t_start_blk t_blk;
  
  for(j=0;j<512;j++)
    buffer[j] = 0;
  
  ip = iget(1, 3);
  ilock(ip);
  if(ip->size < 512*20){ 
    cprintf("alloc journal\n");
    // allocate journal if too small
    for(i=0;i<20;i++){
      writei(ip, buffer, i*512, sizeof(buffer));
    }
  }
  else {
    readi(ip, &t_blk, 0, sizeof(t_blk));
    // check if there is a valid not commited transaction
    if(t_blk.state == READY){
      cprintf("~~~~~~~~~~RECOVERING!!!!!~~~~~~~~~~\n");
      for(i = 0; i < t_blk.num_blks; i++){
	readi(ip, buffer, i*512+512, sizeof(buffer));
	bp = bread(1, t_blk.sector[i]);
	cprintf("recovering sector %d\n", t_blk.sector[i]);
	memmove(bp->data, buffer, sizeof(buffer));
	bwrite(bp);
	brelse(bp);
      }
      writei(ip, buffer, 0, sizeof(buffer));
      cprintf("~~~~~RECOVERY COMPLETE~~~~~~~~\n");
    }
  }
  
  iunlock(ip);
}
开发者ID:alangenfeld,项目名称:xv6,代码行数:41,代码来源:journal.c


示例15: main

int main()
{
	int a[100];
	int i;
	int j;
	int n;
	int err;
	prints("Enter the total number of integers to sort :");
	n = readi(&err);
	prints("Enter the number one by one:\n");
	for(i=0;i<n;i++)
	{
		a[i] = readi(&err);
	}

	prints("Sorting the array. \n");
	int temp;
	for(i=n;i>0;i--)
	{
		for(j=0;j<i-1;j++)
		{
			if(a[j+1]<a[j])
			{
				temp = a[j];
				a[j] = a[j+1];
				a[j+1]=temp;
			}
		}
	}
	prints("Printing the sorted array. \n");
	for(i=0;i<n;i++)
	{
		printi(a[i]);
		prints(" ");
	}
	prints("\n");

	return 0;


}
开发者ID:nishkarsh-shastri,项目名称:Compilers_assignments_2014,代码行数:41,代码来源:ass6_12CS10034_test1.c


示例16: main

int main()
{
	prints("Enter a number whose factorial you want to know: ")	;
	int n,err;
	n = readi(&err);
	int fact;
	fact = factorial(n);
	prints("The value is: ");
	printi(fact);
	prints("\n");

	prints("Enter a number n whose fibonacci(n) you want to know: ");
	n = readi(&err);
	int fib;
	prints("The value is: ");
	fib = fibonacci(n);
	printi(fib);
	prints("\n");
	return 0;

}
开发者ID:nishkarsh-shastri,项目名称:Compilers_assignments_2014,代码行数:21,代码来源:ass6_12CS10034_test4.c


示例17: memcpy

Node::Node(const Block &blk) { // notice here
    char* mem = (char*)malloc(BLOCK_SIZE);
    memcpy(mem, blk.data, BLOCK_SIZE);
    
    isleaf = mem[0]; isroot = mem[1];
    
    mem += 2*sizeof(char);
    int pSize = readi(mem), kSize = readi(mem), typeId = readi(mem), strLen = readi(mem);
    
    //system("pause");
    
    int p = 0;
    
    for( int i = 0; i < pSize; i++ ) {
        p = readi(mem);
        P.push_back(p);
    }
    
    
    for( int i = 0; i < kSize; i++ ) {
        AttrType k;
        
        if( typeId == 0 ) { // int
            k = AttrType(readi(mem));
        }
        else if( typeId == 1 ) { // float
            k = AttrType(readf(mem));
        }
        else if( typeId == 2 ) { // string
            k = AttrType(reads(mem, strLen));
        }
        
        K.push_back(k);
    }
}
开发者ID:AlecWong,项目名称:DBSQL,代码行数:35,代码来源:b_plus_tree.cpp


示例18: main

int main()
{
	prints("Enter three numbers whose maximum among them you want to know\n");
	int a,b,c,err;
	prints("Enter the first number: ");
	a = readi(&err);
	prints("Enter the second number: ");
	b = readi(&err);
	prints("Enter the third number: ");
	c = readi(&err);

	int max;
	max = findmax(a,b,c);

	prints("The max value is: ");
	printi(max);
	prints("\n");

	prints("Lets do expression tests:\n");
	prints("a = b*c*a = ");
	a = b*c*a;
	printi(a);
	prints("\n");

	prints("b = a/c = ");
	b = a/c;
	printi(b);
	prints("\n");
	
	prints("c = a%b = ");
	c = a%b;
	printi(c);
	prints("\n");
		
	return 0;
}
开发者ID:nishkarsh-shastri,项目名称:Compilers_assignments_2014,代码行数:36,代码来源:ass6_12CS10034_test5.c


示例19: _read

int16_t _read(void)
{
	inoptr ino;
	uint8_t flag;

	if (!valaddr(buf, nbytes))
	        return -1;
	/* Set up u_base, u_offset, ino; check permissions, file num. */
	if ((ino = rwsetup(true, &flag)) == NULLINODE)
		return -1;	/* bomb out if error */

	readi(ino, flag);
	updoff();

	return (udata.u_count);
}
开发者ID:Abioy,项目名称:FUZIX,代码行数:16,代码来源:syscall_fs.c


示例20: main

int main()
{
	float x;
	int y;
	prints("Enter a floating point number :");
	if(!readf(&x))
		printd(x);
	else
		prints("Invalid floating point number!");
	prints("\nEnter an integer :");
	if(!readi(&y))
		printi(y);
	else
		prints("Invalid integer!");
	prints("\n");
	return 0;
}
开发者ID:abaheti95,项目名称:TinyC_Compiler,代码行数:17,代码来源:ass2_main.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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