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

C++ char2int函数代码示例

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

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



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

示例1: lj_lex_setup

/* Setup lexer state. */
void lj_lex_setup(lua_State *L, LexState *ls)
{
  ls->L = L;
  ls->fs = NULL;
  ls->n = 0;
  ls->p = NULL;
  ls->vstack = NULL;
  ls->sizevstack = 0;
  ls->vtop = 0;
  ls->bcstack = NULL;
  ls->sizebcstack = 0;
  ls->lookahead = TK_eof;  /* No look-ahead token. */
  ls->linenumber = 1;
  ls->lastline = 1;
  lj_str_resizebuf(ls->L, &ls->sb, LJ_MIN_SBUF);
  next(ls);  /* Read-ahead first char. */
  if (ls->current == 0xef && ls->n >= 2 && char2int(ls->p[0]) == 0xbb &&
      char2int(ls->p[1]) == 0xbf) {  /* Skip UTF-8 BOM (if buffered). */
    ls->n -= 2;
    ls->p += 2;
    next(ls);
  }
  if (ls->current == '#') {  /* Skip POSIX #! header line. */
    do {
      next(ls);
      if (ls->current == END_OF_STREAM) return;
    } while (!currIsNewline(ls));
    inclinenumber(ls);
  }
  if (ls->current == LUA_SIGNATURE[0]) {
    setstrV(L, L->top++, lj_err_str(L, LJ_ERR_XBCLOAD));
    lj_err_throw(L, LUA_ERRSYNTAX);
  }
}
开发者ID:AndreiLazarescu,项目名称:ariavg,代码行数:35,代码来源:lj_lex.c


示例2: encodeHexString

bool encodeHexString(uint8_t *data, uint32_t dataLength, const char* key, bool swapEndian)
{
	if (swapEndian)
	{
		for (int i = dataLength * 2 - 2; i >= 0; i -= 2)
		{
			int c1 = char2int(key[i]);
			int c2 = char2int(key[i + 1]);
			if (c1 == -1 || c2 == -1)
				return false;
			*data++ = c1 * 16 + c2;
		}
	}
	else
	{
		for (int i = 0; i < dataLength * 2; i += 2)
		{
			int c1 = char2int(key[i]);
			int c2 = char2int(key[i + 1]);
			if (c1 == -1 || c2 == -1)
				return false;
			*data++ = c1 * 16 + c2;
		}
	}

	return true;
}
开发者ID:Bushstar,项目名称:bkchaind,代码行数:27,代码来源:Database.cpp


示例3: s

/*
  args:
     s           character string representing hex digits
     len         length of s (it does not need to be null-terminated) 
     intbuf      pre-allocated array of integers into which the result
                 will be placed, 3 bytes per int.  no checks
                 are made as to the length being sufficient, this is the
                 caller's responsibility, strlen(s)/6 + 1 is enough

  returns:
    length of int buf used

  this function packs an array of characters representing hex digits
  into an array of ints, 3 bytes per int
*/
int hexstring2int(char *s, int len, unsigned int *intbuf) {
  int s_ind = 0, int_ind = 0;
  int remainder;
  int i;

  remainder = len%6;
  int_ind = 0;
  intbuf[int_ind] = 0;
  while (remainder && s_ind < len) {
    intbuf[int_ind] = char2int(s[s_ind++]) | (intbuf[int_ind] << 4);
    remainder -=1;
    len-=1;
  }
  if (intbuf[int_ind]) int_ind++;
  
  while (len>0) {
    intbuf[int_ind] = 0;
    for (i=0; i<6; i++) {
      intbuf[int_ind] = char2int(s[s_ind++]) | (intbuf[int_ind] << 4);
    }    
    len -=6;
    int_ind++;
  }
  return(int_ind);
}
开发者ID:nforrester,项目名称:6.834-final-project,代码行数:40,代码来源:base36.c


示例4: str2int

int str2int(char *str){

    //printf("%s\n", str);
    int tam = strlen(str);
    //printf("%d\n", tam);

    int sum = 0;

    int i;

    //printf("\n%d\n", tenPow(4));

    for(i = tam-1; i > 0; i--){
        //printf("%c %d %d\n", str[i], char2int(str[i]), tenPow(tam-1-i));//(tam-1-i)
        sum += (char2int(str[i]) * tenPow(tam-1-i));
    }


    if(str[i] == '-')
        sum *= -1;
    else
        sum += (char2int(str[i]) * tenPow(tam-1));

    //printf(">%d<\n", sum);

    return sum;
}
开发者ID:Lukasavicus,项目名称:ReSync,代码行数:27,代码来源:ReSync2.c


示例5: sim_blosum

int sim_blosum(char* seq1, char* seq2)
{
   int len = (strlen(seq1) < strlen(seq2) ? (int)strlen(seq1) : (int)strlen(seq2));
   int sim = 0;
   for (int i=0; i<len; i++)
      sim = Sum_INT_MIN2(sim,BLOSUM[char2int(seq1[i])][char2int(seq2[i])]);
   return sim;
}
开发者ID:ivohof,项目名称:Barriers,代码行数:8,代码来源:secis_basics.cpp


示例6: while

// This function assumes src to be a zero terminated sanitized string with
// an even number of [0-9a-f] characters, and target to be sufficiently large
void Utils::hex2bin(const uint8_t* src, uint8_t* target)
{  // https://stackoverflow.com/questions/17261798/
  while (*src && src[1])
  {
    *(target++) = char2int(*src) * 16 + char2int(src[1]);
    src += 2;
  }
}
开发者ID:Jesse-V,项目名称:OnioNS-common,代码行数:10,代码来源:Utils.cpp


示例7: parse_cryptokey

static void parse_cryptokey(AVFormatContext *avfc, const char *str) {
    int len = strlen(str) / 2;
    uint8_t *key = av_mallocz(len);
    int i;
    avfc->keylen = len;
    avfc->key = key;
    for (i = 0; i < len; i++, str += 2)
        *key++ = (char2int(str[0]) << 4) | char2int(str[1]);
}
开发者ID:pder,项目名称:mplayer-svn,代码行数:9,代码来源:demux_lavf.c


示例8: main

int main(void)
{
    char (*a)[1000],(*b)[1000],(*c)[1100];
    char sum;
    int T,i = 0,j = 0;
    scanf("%d",&T);
    c = (char (*)[1100])malloc(sizeof(char) * 1100 * T);
    a = (char (*)[1000])malloc(sizeof(char) * 1000 * T);
    b = (char (*)[1000])malloc(sizeof(char) * 1000 * T);

    for(i = 0 ;i < T;i++)
    {
        memset(a[i],0,sizeof(a[i]));
        memset(b[i],0,sizeof(b[i]));
        memset(c[i],0,sizeof(c[i]));

        scanf("%s",a[i]);
        scanf("%s",b[i]);

        int len_a,len_b;
        len_a = strlen(a[i]);
        len_b = strlen(b[i]);
        int carry = 0;
        j = 0;
        while(len_a > j || len_b > j)
        {
            if(j < len_a && j < len_b)
                c[i][j] = char2int(a[i][len_a -1 - j]) + char2int(b[i][len_b -1 - j]) + carry;
            else if(j < len_b && j >= len_a)
                c[i][j] = char2int(b[i][len_b -1 - j]) + carry;
            else if(j < len_a && j >= len_b)
                c[i][j] = char2int(a[i][len_a -1 - j]) + carry;
            else
                break;
            carry = c[i][j] / 10;
            c[i][j] = c[i][j] % 10;
            c[i][j] = int2char(c[i][j]);
            j++;
        }
         if(carry)
             c[i][j] = int2char(carry);
    }
    for(i = 0;i < T ;i++)
    {
         printf("Case %d:\n", i+1);
         printf("%s + %s = ", a[i],b[i]);

         for(j = strlen(c[i]) - 1;j >= 0;j--)
             printf("%c", c[i][j]);
         if(i != T -1)
             printf("\n");
         printf("\n");
    }
    free(a);
    free(b);
    free(c);
}
开发者ID:scofieldsoros,项目名称:hdu,代码行数:57,代码来源:1002.c


示例9: FromHexStringToByte

std::vector<byte> FromHexStringToByte(std::string input)
{
    std::vector<byte> data; //= new byte[input.Length / 2];
    std::string HexByte = "";

    for (int i = 0; i < input.length() / 2; i++) {
        HexByte = input.substr(i * 2, 2);
        unsigned char temp = char2int(HexByte[0]) * 16 + char2int(HexByte[1]);
        data.push_back(temp);
    }

    return data;
}
开发者ID:alexript,项目名称:crypto-gost,代码行数:13,代码来源:main.cpp


示例10: nucchar_to_aaint

int* nucchar_to_aaint(char* nuc_seq)
{
   int nuc_length = (int)strlen(nuc_seq);
   int* int_nuc_seq = char2int(nuc_seq);

   return nucint_to_aaint(int_nuc_seq,nuc_length);
}
开发者ID:ivohof,项目名称:Barriers,代码行数:7,代码来源:secis_basics.cpp


示例11: getWordBlock

Block getWordBlock(std::string word, std::fstream& f, bool createIfReauired = false) {
  seekRW(f, 0);
  BlockOffset currentOffset = 0;
  Block b {readBlockFromFile(f)};

  for(auto c : word) {
    unsigned int i = char2int(c);

    if (b.offsets[i] == 0 ) {
      if (!createIfReauired) {
	b.data=0;
	return b;
      }
      BlockOffset off = f.tellp();
      Block newBlock {};
      seekRW(f, 0, f.end); 
      BlockOffset newCurrent = b.offsets[i] = writeBlockToFile(newBlock, f);
      seekRW(f, off);
      writeBlockToFile(b, f);
      seekRW(f, newCurrent);
      currentOffset = newCurrent;
      b = newBlock;
    } else {
      currentOffset = b.offsets[i];
      seekRW(f, currentOffset);
      b = readBlockFromFile(f);
    }
  }

  return b;
}
开发者ID:UIKit0,项目名称:superindexer,代码行数:31,代码来源:superindexer.cpp


示例12: lj_lex_setup

/* Setup lexer state. */
int lj_lex_setup(lua_State *L, LexState *ls)
{
  int header = 0;
  ls->L = L;
  ls->fs = NULL;
  ls->n = 0;
  ls->p = NULL;
  ls->vstack = NULL;
  ls->sizevstack = 0;
  ls->vtop = 0;
  ls->bcstack = NULL;
  ls->sizebcstack = 0;
  ls->lookahead = TK_eof;  /* No look-ahead token. */
  ls->linenumber = 1;
  ls->lastline = 1;
  lj_str_resizebuf(ls->L, &ls->sb, LJ_MIN_SBUF);
  next(ls);  /* Read-ahead first char. */
  if (ls->current == 0xef && ls->n >= 2 && char2int(ls->p[0]) == 0xbb &&
      char2int(ls->p[1]) == 0xbf) {  /* Skip UTF-8 BOM (if buffered). */
    ls->n -= 2;
    ls->p += 2;
    next(ls);
    header = 1;
  }
  if (ls->current == '#') {  /* Skip POSIX #! header line. */
    do {
      next(ls);
      if (ls->current == END_OF_STREAM) return 0;
    } while (!currIsNewline(ls));
    inclinenumber(ls);
    header = 1;
  }
  if (ls->current == LUA_SIGNATURE[0]) {  /* Bytecode dump. */
    if (header) {
      /*
      ** Loading bytecode with an extra header is disabled for security
      ** reasons. This may circumvent the usual check for bytecode vs.
      ** Lua code by looking at the first char. Since this is a potential
      ** security violation no attempt is made to echo the chunkname either.
      */
      setstrV(L, L->top++, lj_err_str(L, LJ_ERR_BCBAD));
      lj_err_throw(L, LUA_ERRSYNTAX);
    }
    return 1;
  }
  return 0;
}
开发者ID:wenhulove333,项目名称:ScutServer,代码行数:48,代码来源:lj_lex.c


示例13: luaZ_fill

int luaZ_fill (ZIO *z) {
  size_t size;
  const char *buff = z->reader(NULL, z->data, &size);
  if (buff == NULL || size == 0) return EOZ;
  z->n = size - 1;
  z->p = buff;
  return char2int(*(z->p++));
}
开发者ID:foreverlikeyou9999,项目名称:kos-ports,代码行数:8,代码来源:lzio.c


示例14: sensownyBIK

bool sensownyBIK(std::string B)
{
    bool kontrola = true;

    kontrola &= (B.size() == 10);


    if(kontrola)
    {
        for(int i=0; i < 11; i++)
            {
                if(0 <= char2int(B[i]) && char2int(B[i]) <= 9);
                else kontrola = false;
            }
    }

    return kontrola;
}
开发者ID:mmaku,项目名称:Cpp_2,代码行数:18,代码来源:bio.cpp


示例15: fillbuf

static int fillbuf(LexState *ls)
{
  size_t sz;
  const char *buf = ls->rfunc(ls->L, ls->rdata, &sz);
  if (buf == NULL || sz == 0) return END_OF_STREAM;
  ls->n = (MSize)sz - 1;
  ls->p = buf;
  return char2int(*(ls->p++));
}
开发者ID:wenhulove333,项目名称:ScutServer,代码行数:9,代码来源:lj_lex.c


示例16: pat2int

unsigned long long pat2int(const char *pat)
{
    unsigned long long val = 0;
    while (*pat) {
        val = (val << 4) + char2int(*pat);
        pat += 1;
    }
    return val;
}
开发者ID:loveshell,项目名称:libinjection,代码行数:9,代码来源:sqlparse.c


示例17: luaZ_lookahead

int luaZ_lookahead (ZIO *z) {
  if (z->n == 0) {
    int c = luaZ_fill(z);
    if (c == EOZ) return c;
    z->n++;
    z->p--;
  }
  return char2int(*z->p);
}
开发者ID:foreverlikeyou9999,项目名称:kos-ports,代码行数:9,代码来源:lzio.c


示例18: file2

void ChannelH11::InputManagement(){
    static double h41[1000][300] = {0};
    //load pilot data
    QFile file2("./pilot/pilot_100_re.txt");
    if (!file2.open(QIODevice::ReadOnly | QIODevice::Text))
        qDebug() << file2.errorString() <<" NO FILE";
    QFile file3("./pilot/pilot_100_im.txt");
    if (!file3.open(QIODevice::ReadOnly | QIODevice::Text))
        qDebug() << file3.errorString() <<" NO FILE";

    char str[100];
    for( int i = 0 ; i < 100 ; i++){
        file2.readLine(str,100);
        int crr = char2int(str);
        pilot[i][0] = crr;
        //qDebug() << "pilot[ "<<i<<" ][0] is :" << pilot[i][0];
        file3.readLine(str,100);
        crr = char2int(str);
        pilot[i][1] = crr;
        //qDebug() << "pilot[ "<<i<<" ][1] is :" << pilot[i][1] << endl;
    }//for



    QFile file("h_300_1000_re.txt");
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
        qDebug() << file.errorString();

    int length = 1000;
    for( int i = 0 ; i < length ; i++ ){
        for( int j = 0 ; j < 300 ; j++ ){
            file.readLine(str,100);
            double crr = 0;
            crr = char2double(str);
            //qDebug() << "crr is :"<<crr;
            //h41[i][j] = crr*10;
            h41[i][j] = 0;
        }
    }
    //qDebug() << "h41[40][299] one is :"<< h41[40][299] ;
    pdata = &h41[0][0];
    pdata2 = pdata;
    file.close();
}
开发者ID:uestcmy,项目名称:QT-Plot---Channe-2X2,代码行数:44,代码来源:channelh11.cpp


示例19: file

void ChannelH11::InputManagement2(){
    //QFile file("datain.txt");

    QFile file("./Pilot_send_data/pilot_1200_re.txt");
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){
        qDebug() << file.errorString();
        qDebug() << "Last sentence is in QPSK Inputmanagement." << endl;

    }
    //qDebug() << QObject::tr("file text:") << endl << file.readAll();
    //char str[100];
    char str[100];
    for( int i = 0 ; i < 1200 ; i++ ){
        file.readLine(str,100);
        int crr = 0;
        crr = char2int(str);
        qDebug() << "pilot[ "<< i <<"][0] is :"<<crr;
        pilot[i][0] = crr;
    }

    //qDebug() << "last one is :"<< qpsk[9][0] ;
    file.close();

    QFile file2("./Pilot_send_data/pilot_1200_im.txt");
    if (!file2.open(QIODevice::ReadOnly | QIODevice::Text)){
        qDebug() << file2.errorString();
        qDebug() << "Last sentence is in QPSK Inputmanagement." << endl;
    }
    //qDebug() << QObject::tr("file text:") << endl << file.readAll();
    //char str[100];
    for( int i = 0 ; i < 1200 ; i++ ){
        file2.readLine(str,100);
        int crr = 0;
        crr = char2int(str);
      qDebug() << "pilot[ "<< i <<"][1] is :"<<crr;
        pilot[i][1] = crr;
    }


    //qDebug() <<"apsk[0][0] is :"<< *(pdata) << endl;
    file2.close();
}
开发者ID:uestcmy,项目名称:704-Channel2D,代码行数:42,代码来源:channelh11.cpp


示例20: luaZ_lookahead

int luaZ_lookahead (ZIO *z) {
  if (z->n == 0) {
    if (luaZ_fill(z) == EOZ)
      return EOZ;
    else {
      z->n++;  /* luaZ_fill removed first byte; put back it */
      z->p--;
    }
  }
  return char2int(*z->p);
}
开发者ID:AwkwardDev,项目名称:Summit,代码行数:11,代码来源:lzio.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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