您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ ungetc函数代码示例

51自学网 2021-06-03 09:09:38
  C++
这篇教程C++ ungetc函数代码示例写得很实用,希望能帮到您。

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

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

示例1: parseline

int parseline( char* c1, char* c2, char* def){    size_t i = 1000;    int j, k, l, m;    int end = 0;    char c;    j = k = l = m = 0;    if(j = fscanf(stdin, " %s", c1))    {        while(isspace(c = getchar()))        {            if(c == '/n')            {                end = 1;                break;            }        }        m = ungetc(c, stdin);        if(!end && (k = fscanf(stdin, " %s", c2)))        {            while(isspace(c = getchar()))            {                if(c == '/n')                {                    end = 1;                    break;                }            }            if(!end)            {                m = ungetc(c, stdin);                l = getline(&def, &i, stdin);                def[l-1] = '/0';            }        }    }    if(!strcmp(c1, "add"))    {        if(k&&l)        {            return 1;        }        else return -1;    }    else if(!strcmp(c1, "find"))    {        if(k)        {            if(l)                return 7;            else                return 3;        }        else return -3;    }    else if(!strcmp(c1, "delete"))    {        if(k)        {            return 2;        }        else return -2;    }    else if(!strcmp(c1, "print"))    {        return 4;    }    else if(!strcmp(c1, "read"))    {        if(k)        {            return 6;        }        else return -5;    }    else if(!strcmp(c1, "exit"))    {        return 5;    }    else if(!strcmp(c1, "test"))    {        if(k)            return 8;    }    return -4;}
开发者ID:asad-iqbal-ali,项目名称:Dictionary,代码行数:100,


示例2: f_collect

/* The function f_collect() reads a string that has the format of a * floating-point number. The function returns as soon as a format-error * is encountered, leaving the offending character in the input. This means * that 1.el leaves the 'l' in the input queue. Since all detection of * format errors is done here, _doscan() doesn't call strtod() when it's * not necessary, although the use of the width field can cause incomplete * numbers to be passed to strtod(). (e.g. 1.3e+) */static char *f_collect(register int c, register FILE *stream, register unsigned int width){	register char *bufp = inp_buf;	int digit_seen = 0;	if (c == '-' || c == '+') {		*bufp++ = c;		if (--width)			c = getc(stream);	}	while (width && isdigit(c)) {		digit_seen++;		*bufp++ = c;		if (--width)			c = getc(stream);	}	if (width && c == '.') {		*bufp++ = c;		if(--width)			c = getc(stream);		while (width && isdigit(c)) {			digit_seen++;			*bufp++ = c;			if (--width)				c = getc(stream);		}	}	if (!digit_seen) {		if (width && c != EOF) ungetc(c, stream);		return inp_buf - 1;	}	else digit_seen = 0;	if (width && (c == 'e' || c == 'E')) {		*bufp++ = c;		if (--width)			c = getc(stream);		if (width && (c == '+' || c == '-')) {			*bufp++ = c;			if (--width)				c = getc(stream);		}		while (width && isdigit(c)) {			digit_seen++;			*bufp++ = c;			if (--width)				c = getc(stream);		}		if (!digit_seen) {			if (width && c != EOF) ungetc(c,stream);			return inp_buf - 1;		}	}	if (width && c != EOF) ungetc(c, stream);	*bufp = '/0';	return bufp - 1;}
开发者ID:locosoft1986,项目名称:nucleos,代码行数:69,


示例3: test_eof

static int test_eof (lua_State *L, FILE *f) {  int c = getc(f);  ungetc(c, f);  lua_pushlstring(L, NULL, 0);  return (c != EOF);}
开发者ID:zauguin,项目名称:LuaTeX,代码行数:6,


示例4: processAIFF

/**Process the AIFF file.  This method will call processCOMM to handle the COMM section.  It will mark the position of the sound file so processSSND and getSamplesAIFF can perform correctly. **/File_Data processAIFF(FILE *outfile, FILE* infile){	int foundComm = 0;	int foundSSND = 0;	File_Data data;	CommonChunk comm;	SoundDataChunk sdc;	data.samples = -1;	data.channels = -1;	data.sampleRate = -1;	data.bitDepth = -1;	data.success = 0;	char buff[4];	int i, j;	for(i = 0; i < 4; i++){		buff[i] = fgetc(infile);	}	flipBytes(buff, 4);	int y = *((int*)buff);	for(i = 0; i < 4; i++){		buff[i] = fgetc(infile);	}	if(strncmp(buff, "AIFF", 4) != 0){		data.success = 0;		return data;	}else {		strncpy(data.format, "AIFF/0", 5);	}	while(!foundComm || !foundSSND){		buff[0] = fgetc(infile);		if(EOF == buff[0]){			data.success = 0;			return data;		}else if(buff[0] != 'C' && buff[0] != 'S' && buff[0] != 'A'){			continue;		}		for(i = 1; i < 4; i++){			buff[i] = fgetc(infile);			if(buff[i] == 'C'){				ungetc(buff[i], infile);				continue;			}		}		if(strncmp(buff, "COMM", 4) == 0){			comm = processComm(infile);			data.samples = comm.numSampleFrames;			data.channels = comm.numChannels;			data.sampleRate = comm.sampleRate;			data.bitDepth = comm.sampleSize;			strcpy(data.duration, findDuration(data.sampleRate, data.channels, data.samples, data.duration));			foundComm = 1;		}		if(strncmp(buff, "SSND", 4) == 0){			/*Marks the position of the SSND chunk so it can be processed later*/			foundSoundData = fgetpos(infile, &SSNDLocation);			foundSSND = 1;		}		if(strncmp(buff, "COMT", 4) == 0 || strncmp(buff, "ANNO", 4) == 0 ){			/* Runs through comment chunks */			int chunkSize;			char sizeBuff[4];			for(j = 0; j < 4; j++){				sizeBuff[j] = fgetc(infile);			}			flipBytes(sizeBuff, 4);			chunkSize = *((int *)sizeBuff);			int count = 0;			while(count < chunkSize){				count++;				fgetc(infile);			}		}	}	if(foundSSND && foundComm)		data.success = 1;	return data;}
开发者ID:CalebTVanDyke,项目名称:Advanced-Programing-Projects,代码行数:88,


示例5: FILE_from_erlangv

//.........这里部分代码省略.........	if (feof(desc->fp))	    driver_ret32(desc->port, 1);	else	    driver_ret32(desc->port,0);	break;    case XX_ERROR:	if (ferror(desc->fp))	    driver_ret32(desc->port, 1);	else	    driver_ret32(desc->port,0);	break;    case XX_GETC: {	int ch;	if ((ch = getc(desc->fp)) == EOF) {	    if (feof(desc->fp)) {		driver_eof(desc->port);		return;	    }	    driver_error(desc->port, errno);	    return;	}	driver_ret32(desc->port, ch);	break;    }    case XX_SET_LINEBUF_SIZE: {	int sz = get_int32((&iov[1])->iov_base+1);	desc->linebuf_size = sz;	driver_ok(desc->port);	break;    }    case XX_GETS:    case XX_GETS2: {	int rval;	long cpos1, cpos2;	char header;		if ((bin = driver_alloc_binary(desc->linebuf_size)) == NULL) {	    driver_error(desc->port, -1);	    return;	}	if ((cpos1 = ftell(desc->fp)) == -1) {	    driver_free_binary(bin);	    driver_error(desc->port, errno);	    return;	}	if ((fgets(bin->orig_bytes, desc->linebuf_size,		   desc->fp)) == NULL) {	    driver_free_binary(bin);	    if (feof(desc->fp)) {		driver_eof(desc->port);		return;	    }	    driver_error(desc->port, errno);	    return;	}	if ((cpos2 = ftell(desc->fp)) == -1) {	    driver_free_binary(bin);	    driver_error(desc->port, errno);	    return;	}	rval = cpos2 - cpos1;	if (bin->orig_bytes[rval-1] == '/n' &&	    bin->orig_bytes[rval] == 0) {	    header = XX_FLINE;	    /* GETS keep newline, GETS2 remove newline */	    rval = rval - ((&iov[1])->iov_base[0] == XX_GETS ? 0 : 1);	}	else	    header = XX_NOLINE;	driver_output_binary(desc->port, &header, 1,bin, 0, rval);	driver_free_binary(bin);	break;    }    case XX_UNGETC: {	int ch = (&iov[1])->iov_base[1];	if (ungetc(ch, desc->fp) == EOF)	    driver_error(desc->port, errno);	else	    driver_ok(desc->port);	break;    }        default:#ifdef DEBUG	fprintf(stderr, "Unknown opcode %c/n/r", ((&iov[1])->iov_base[0]));#endif	driver_error(desc->port, XX_EINVAL);	break;    }		}
开发者ID:Jasson,项目名称:devdb,代码行数:101,


示例6: fgetc

csdbparser::enResult csdbparser::symbolread(sym_data *data, symdata_pack* pack){    if (m_debug) printf("=====> symbolread/n");    int ch, ch2;    data->clear();    data->valid = true;    data->sym_type = sym_data::symNone;    ch = fgetc(m_fp);    if (m_debug) printf("check3!  %c/n", (char)ch);    if (ch == 9) // TAB    {        ch = fgetc(m_fp);        if (m_debug) printf("check4!  %c/n", (char)ch);        switch (ch)        {        case '}': // end of func            if (m_calling_func.size() > 0)                m_calling_func.clear();            else if (m_debug) printf("no func to clear!/n");            data->valid = false;            if (m_debug) printf("End of func found/n");            break;        case ')': // end of macro            if (m_calling_macro.size() > 0)                m_calling_macro.clear();            else if (m_debug) printf("no macro to clear!/n");            data->valid = false;            if (m_debug) printf("End of macro found/n");            break;        case '~': // include            ch2 = fgetc(m_fp);            if ((ch2 == '"')||(ch2 == '<'))            {                pack->line_text += (char) ch2;            }            else            {                ungetc(ch2, m_fp);            }            data->sym_type = sym_data::symIncl;            if (m_debug) printf("Incl found/n");            break;        default:            for (int i=0; i<symbtypetbl_SIZE; i++)            {                if (symbtypetbl[i].chr == ch)                {                    data->sym_type =                        symbtypetbl[i].type;                    break;                }            }            if (data->sym_type == sym_data::symNone)                return resUNKNOWN_ERR;            break;        };    }    else ungetc(ch, m_fp);    if (fgets(m_buf, m_bufsize, m_fp) == NULL)    {        return resFILE_ACCESS_ERR;    }    data->symbname = chomp(m_buf);    if (data->valid) data->valid = (strlen(data->symbname.c_str()) > 0);    if (m_debug) printf("sym name=%s, type = %s, valid=%d, ch=%c/n",                            data->symbname.c_str(), data->getTypeDesc(), data->valid, ch);    if      (ch == '$')    {        m_calling_func.assign(data->symbname);    }    else if (ch == '#')    {        m_calling_macro.assign(data->symbname);    }    else if (ch == '`')    {        data->calling_func = m_calling_func;        data->calling_macro = m_calling_macro;    }    return resOK;}
开发者ID:hxvu,项目名称:xstatic,代码行数:81,


示例7: rc_ungetc

static inline int rc_ungetc (char c, FILE *rc) {  pos--;  return ungetc (c, rc);}
开发者ID:svn2github,项目名称:xqf,代码行数:4,


示例8: brackets

/* Extract from the stream the longest string of characters which are neither   whitespace nor brackets (except for an optional bracketed n-char_sequence   directly following nan or @[email
C++ ungetch函数代码示例
C++ unget函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。