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

C++ Getline函数代码示例

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

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



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

示例1: pcre_compile

/* -----------------------------------------------------------------------------
 * Swig_string_regex()
 *
 * Executes a regular expression substitution. For example:
 *
 *   Printf(stderr,"gsl%(regex:/GSL_.*_/\\1/)s","GSL_Hello_") -> gslHello
 * ----------------------------------------------------------------------------- */
String *Swig_string_regex(String *s) {
  const int pcre_options = 0;

  String *res = 0;
  pcre *compiled_pat = 0;
  const char *pcre_error, *input;
  int pcre_errorpos;
  String *pattern = 0, *subst = 0;
  int captures[30];

  if (split_regex_pattern_subst(s, &pattern, &subst, &input)) {
    int rc;

    compiled_pat = pcre_compile(
          Char(pattern), pcre_options, &pcre_error, &pcre_errorpos, NULL);
    if (!compiled_pat) {
      Swig_error("SWIG", Getline(s), "PCRE compilation failed: '%s' in '%s':%i.\n",
          pcre_error, Char(pattern), pcre_errorpos);
      exit(1);
    }
    rc = pcre_exec(compiled_pat, NULL, input, (int)strlen(input), 0, 0, captures, 30);
    if (rc >= 0) {
      res = replace_captures(rc, input, subst, captures, pattern, s);
    } else if (rc != PCRE_ERROR_NOMATCH) {
      Swig_error("SWIG", Getline(s), "PCRE execution failed: error %d while matching \"%s\" using \"%s\".\n",
	rc, Char(pattern), input);
      exit(1);
    }
  }

  DohDelete(pattern);
  DohDelete(subst);
  pcre_free(compiled_pat);
  return res ? res : NewStringEmpty();
}
开发者ID:EemeliSyynimaa,项目名称:yam2d,代码行数:42,代码来源:misc.c


示例2: Swig_name_regexmatch_value

int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
  pcre *compiled_pat;
  const char *err;
  int errpos;
  int rc;

  compiled_pat = pcre_compile(Char(pattern), 0, &err, &errpos, NULL);
  if (!compiled_pat) {
    Swig_error("SWIG", Getline(n),
               "Invalid regex \"%s\": compilation failed at %d: %s\n",
               Char(pattern), errpos, err);
    exit(1);
  }

  rc = pcre_exec(compiled_pat, NULL, Char(s), Len(s), 0, 0, NULL, 0);
  pcre_free(compiled_pat);

  if (rc == PCRE_ERROR_NOMATCH)
    return 0;

  if (rc < 0 ) {
    Swig_error("SWIG", Getline(n),
               "Matching \"%s\" against regex \"%s\" failed: %d\n",
               Char(s), Char(pattern), rc);
    exit(1);
  }

  return 1;
}
开发者ID:progranism,项目名称:Allegro-5-SWIG-Wrapper,代码行数:29,代码来源:naming.c


示例3: main

int main()
{
	char s1[MAXLINE], s2[MAXLINE];
	Getline(s1, MAXLINE);
	Getline(s2, MAXLINE);
	printf("%d\n", any(s1, s2));
	return 0;
}
开发者ID:RuohengLiu,项目名称:learn-to-code,代码行数:8,代码来源:2-05.c


示例4: Swig_extend_merge

void Swig_extend_merge(Node *cls, Node *am) {
  Node *n;
  Node *csym;

  n = firstChild(am);
  while (n) {
    String *symname;
    if (Strcmp(nodeType(n),"constructor") == 0) {
      symname = Getattr(n,"sym:name");
      if (symname) {
	if (Strcmp(symname,Getattr(n,"name")) == 0) {
	  /* If the name and the sym:name of a constructor are the same,
             then it hasn't been renamed.  However---the name of the class
             itself might have been renamed so we need to do a consistency
             check here */
	  if (Getattr(cls,"sym:name")) {
	    Setattr(n,"sym:name", Getattr(cls,"sym:name"));
	  }
	}
      } 
    }

    symname = Getattr(n,"sym:name");
    DohIncref(symname);
    if ((symname) && (!Getattr(n,"error"))) {
      /* Remove node from its symbol table */
      Swig_symbol_remove(n);
      csym = Swig_symbol_add(symname,n);
      if (csym != n) {
	/* Conflict with previous definition.  Nuke previous definition */
	String *e = NewStringEmpty();
	String *en = NewStringEmpty();
	String *ec = NewStringEmpty();
	Printf(ec,"Identifier '%s' redefined by %%extend (ignored),",symname);
	Printf(en,"%%extend definition of '%s'.",symname);
	SWIG_WARN_NODE_BEGIN(n);
	Swig_warning(WARN_PARSE_REDEFINED,Getfile(csym),Getline(csym),"%s\n",ec);
	Swig_warning(WARN_PARSE_REDEFINED,Getfile(n),Getline(n),"%s\n",en);
	SWIG_WARN_NODE_END(n);
	Printf(e,"%s:%d:%s\n%s:%d:%s\n",Getfile(csym),Getline(csym),ec, 
	       Getfile(n),Getline(n),en);
	Setattr(csym,"error",e);
	Delete(e);
	Delete(en);
	Delete(ec);
	Swig_symbol_remove(csym);              /* Remove class definition */
	Swig_symbol_add(symname,n);            /* Insert extend definition */
      }
    }
    n = nextSibling(n);
  }
}
开发者ID:kkaempf,项目名称:swig,代码行数:52,代码来源:extend.c


示例5: split_regex_pattern_subst

static int split_regex_pattern_subst(String *s, String **pattern, String **subst, const char **input)
{
  const char *pats, *pate;
  const char *subs, *sube;

  /* Locate the search pattern */
  const char *p = Char(s);
  if (*p++ != '/') goto err_out;
  pats = p;
  p = strchr(p, '/');
  if (!p) goto err_out;
  pate = p;

  /* Locate the substitution string */
  subs = ++p;
  p = strchr(p, '/');
  if (!p) goto err_out;
  sube = p;

  *pattern = NewStringWithSize(pats, (int)(pate - pats));
  *subst   = NewStringWithSize(subs, (int)(sube - subs));
  *input   = p + 1;
  return 1;

err_out:
  Swig_error("SWIG", Getline(s), "Invalid regex substitution: '%s'.\n", s);
  exit(1);
}
开发者ID:EemeliSyynimaa,项目名称:yam2d,代码行数:28,代码来源:misc.c


示例6: VetoThres2

void VetoThres2(Int_t Lo, Int_t Hi)
{
  TCanvas* Window;
  TTimer* Refresh;
  TH1F* Energy;
  Char_t Buff[256];
  Char_t* Keyb;
  Double_t Pos[438];

  Window = new TCanvas();
  Window->SetCrosshair();
  Window->ToggleEventStatus();
  Refresh = new TTimer("Flush()", 50, kFALSE);
  for(Int_t ch=Lo; ch<Hi+1; ch++)
  {
    sprintf(Buff, "Veto_Energy%d", ch);
    Energy = (TH1F*)gROOT->FindObject(Buff);
    Energy->GetXaxis()->SetRange(0, 250);
    Energy->Draw();
    Window->Update();
    sprintf(Buff, "Threshold for %d: ", ch);
    Refresh->TurnOn();
    Refresh->Reset();
    Keyb = Getline(Buff);
    Refresh->TurnOff();
    Pos[ch] = atof(Keyb);
  }
  for(Int_t ch=Lo; ch<Hi+1; ch++)
    printf("%5.1f\n", Pos[ch]);
}
开发者ID:A2-Collaboration,项目名称:acqu,代码行数:30,代码来源:LadderTimes.cpp


示例7: strchr

/* internal function for processing an encoding */
static DOH *encode(char *name, DOH *s) {
    DOH *handle, *ns;
    DOH *(*fn) (DOH *);
    long pos;
    char *cfmt = strchr(name, ':');
    DOH *tmp = 0;
    if (cfmt) {
        tmp = NewString(cfmt + 1);
        Append(tmp, s);
        Setfile(tmp, Getfile((DOH *) s));
        Setline(tmp, Getline((DOH *) s));
        *cfmt = '\0';
    }
    if (!encodings || !(handle = Getattr(encodings, name))) {
        return Copy(s);
    }
    if (tmp)
        s = tmp;
    pos = Tell(s);
    Seek(s, 0, SEEK_SET);
    fn = (DOH *(*)(DOH *)) Data(handle);
    ns = (*fn) (s);
    Seek(s, pos, SEEK_SET);
    if (tmp)
        Delete(tmp);
    return ns;
}
开发者ID:sunaku,项目名称:swig-ruby-ffi,代码行数:28,代码来源:fio.c


示例8: Getattr

Hash *Swig_name_namewarn_get(Node *n, String *prefix, String *name, SwigType *decl) {
  if (!namewarn_hash && !namewarn_list)
    return 0;
  if (n) {
    /* Return in the obvious cases */
    if (!name || !Swig_need_name_warning(n)) {
      return 0;
    } else {
      String *access = Getattr(n, "access");
      int is_public = !access || Equal(access, "public");
      if (!is_public && !Swig_need_protected(n)) {
	return 0;
      }
    }
  }
  if (name) {
    /* Check to see if the name is in the hash */
    Hash *wrn = Swig_name_object_get(Swig_name_namewarn_hash(), prefix, name, decl);
    if (wrn && !Swig_name_match_nameobj(wrn, n))
      wrn = 0;
    if (!wrn) {
      wrn = Swig_name_nameobj_lget(Swig_name_namewarn_list(), n, prefix, name, decl);
    }
    if (wrn && Getattr(wrn, "error")) {
      if (n) {
	Swig_error(Getfile(n), Getline(n), "%s\n", Getattr(wrn, "name"));
      } else {
	Swig_error(cparse_file, cparse_line, "%s\n", Getattr(wrn, "name"));
      }
    }
    return wrn;
  } else {
    return 0;
  }
}
开发者ID:progranism,项目名称:Allegro-5-SWIG-Wrapper,代码行数:35,代码来源:naming.c


示例9: NewStringEmpty

String *Swig_stringify_with_location(DOH *object) {
  String *str = NewStringEmpty();

  if (!init_fmt)
    Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);

  if (object) {
    int line = Getline(object);
    String *formatted_filename = format_filename(Getfile(object));
    if (line > 0) {
      Printf(str, diag_line_fmt, formatted_filename, line);
    } else {
      Printf(str, diag_eof_fmt, formatted_filename);
    }
    if (Len(object) == 0) {
      Printf(str, "[EMPTY]");
    } else {
      Printf(str, "[%s]", object);
    }
    Delete(formatted_filename);
  } else {
    Printf(str, "[NULL]");
  }

  return str;
}
开发者ID:FlorianDeconinck,项目名称:angel2d,代码行数:26,代码来源:error.c


示例10: NewStringEmpty

String *replace_captures(int num_captures, const char *input, String *subst, int captures[], String *pattern, String *s)
{
  String *result = NewStringEmpty();
  const char *p = Char(subst);

  while (*p) {
    /* Copy part without substitutions */
    const char *q = strchr(p, '\\');
    if (!q) {
      Write(result, p, strlen(p));
      break;
    }
    Write(result, p, q - p);
    p = q + 1;

    /* Handle substitution */
    if (*p == '\0') {
      Putc('\\', result);
    } else if (isdigit((unsigned char)*p)) {
      int group = *p++ - '0';
      if (group < num_captures) {
	int l = captures[group*2], r = captures[group*2 + 1];
	if (l != -1) {
	  Write(result, input + l, r - l);
	}
      } else {
	Swig_error("SWIG", Getline(s), "PCRE capture replacement failed while matching \"%s\" using \"%s\" - request for group %d is greater than the number of captures %d.\n",
	    Char(pattern), input, group, num_captures-1);
      }
    }
  }

  return result;
}
开发者ID:Distrotech,项目名称:swig,代码行数:34,代码来源:misc.c


示例11: main

int main()	/* Reverse Polish notation */
{
	int type;
	double op2;
	char s[MAXOP];
	double ans = 0.0;
	while (Getline(expression, MAXOP))
		while ((type = getop(s)) != EOF) {
			switch (type) {
				case NUMBER:
					push(atof(s));
					break;
				case 'a':
					push(ans);
					break;
				case '+':
					push(pop() + pop());
					break;
				case '*':
					push(pop() * pop());
					break;
				case '-':
					op2 = pop();
					push(pop() - op2);
					break;
				case '/':
					op2 = pop();
					if (op2 != 0.0) push(pop() / op2);
					else printf("error: zero divisor\n");
					break;
				case '%':
					op2 = pop();
					if (op2 != 0.0) push(fmod(pop(), op2));	/* use g++ to compile */
					else printf("error: zero divisor\n");
					break;
				case SIN:
					push(sin(pop()));
					break;
				case EXP:
					push(exp(pop()));
					break;
				case POW:
					op2 = pop();
					push(pow(pop(), op2));
					break;
				case '\n':
					ans = pop();
					printf("\t%.8g\n", ans);
					break;
				default:
					printf("error: unknown command %s\n", s);
					break;
			}
			if (type == '\n') break;
		}
	return 0;
}
开发者ID:RuohengLiu,项目名称:learn-to-code,代码行数:57,代码来源:4-10-main.c


示例12: SwigScanner_push

void 
SwigScanner_push(SwigScanner *s, String *txt) {
  assert(s && txt);
  Push(s->scanobjs,txt);
  if (s->str) Delete(s->str);
  s->str = txt;
  DohIncref(s->str);
  s->line = Getline(txt);
}
开发者ID:kanbang,项目名称:Colt,代码行数:9,代码来源:scanner.c


示例13: Swig_require

int 
Swig_require(const char *ns, Node *n, ...) {
  va_list ap;
  char *name;
  DOH *obj;
  char   temp[512];

  va_start(ap, n);
  name = va_arg(ap, char *);
  while (name) {
    int newref = 0;
    int opt = 0;
    if (*name == '*') {
      newref = 1;
      name++;
    } else if (*name == '?') {
      newref = 1;
      opt = 1;
      name++;
    }
    obj = Getattr(n,name);
    if (!opt && !obj) {
      Printf(stderr,"%s:%d. Fatal error (Swig_require).  Missing attribute '%s' in node '%s'.\n", 
	     Getfile(n), Getline(n), name, nodeType(n));
      assert(obj);
    }
    if (!obj) obj = DohNone;
    if (newref) {
      /* Save a copy of the attribute */
      strcpy(temp,ns);
      strcat(temp,":");
      strcat(temp,name);
      Setattr(n,temp,obj);
    } 
    name = va_arg(ap, char *);
  }
  va_end(ap);

  /* Save the view */
  {
    String *view = Getattr(n,"view");
    if (view) {
      if (Strcmp(view,ns) != 0) {
	strcpy(temp,ns);
	strcat(temp,":view");
	Setattr(n,temp,view);
	Setattr(n,"view",ns);
      }
    } else {
      Setattr(n,"view",ns);
    }
  }

  return 1;
}
开发者ID:janearc,项目名称:posixnap_old,代码行数:55,代码来源:tree.c


示例14: main

int main()
{
	int i;
	char len[MAX_LEN];

	Getline(len, MAX_LEN);
	for(i = 0; len[i] != '\0'; i++)
		;
	reverse_line(len, i);
	
}
开发者ID:wxiaodong0829,项目名称:aka_edu_learned,代码行数:11,代码来源:reverse_doc.c


示例15: main

int main()
{
	char line[MAXLINE];
	int found = 0;

	while (Getline(line, MAXLINE) > 0)
		if (strrindex(line, pattern) >= 0) {
			printf("%s", line);
			found++;
		}
	return found;
}
开发者ID:RuohengLiu,项目名称:learn-to-code,代码行数:12,代码来源:4-01-main.c


示例16: Swig_extend_unused_check

void Swig_extend_unused_check(void) {
  Iterator ki;

  if (!extendhash) return;
  for (ki = First(extendhash); ki.key; ki = Next(ki)) {
    if (!Strchr(ki.key,'<')) {
      SWIG_WARN_NODE_BEGIN(ki.item);
      Swig_warning(WARN_PARSE_EXTEND_UNDEF,Getfile(ki.item), Getline(ki.item), "%%extend defined for an undeclared class %s.\n", SwigType_namestr(ki.key));
      SWIG_WARN_NODE_END(ki.item);
    }
  }
}
开发者ID:kkaempf,项目名称:swig,代码行数:12,代码来源:extend.c


示例17: NewHash

Node *copyNode(Node *n) {
  Iterator ki;
  Node *c = NewHash();
  for (ki = First(n); ki.key; ki = Next(ki)) {
    if (DohIsString(ki.item)) {
      Setattr(c, ki.key, Copy(ki.item));
    }
  }
  Setfile(c, Getfile(n));
  Setline(c, Getline(n));
  return c;
}
开发者ID:GSGroup,项目名称:swig-v8,代码行数:12,代码来源:tree.c


示例18: wait

/************ wait funtion !!  *************************************************************** 
*********************************************************************************************/
void wait(){

	TTimer *timer = new TTimer("gSystem->ProcessEvents();", 50, kFALSE);
	char *input;
	Bool_t done = kFALSE;
	do{
		timer->TurnOn();
		timer->Reset();
		input=Getline("Type <return> to continue : ");
		timer->TurnOff();
		if(input){			done =kTRUE;		}	
	}while(!done);
}
开发者ID:samchen03,项目名称:rootMacro,代码行数:15,代码来源:read_scope_spect.c


示例19: SwigScanner_skip_line

void
SwigScanner_skip_line(SwigScanner *s) {
    char c;
    int done = 0;
    Clear(s->text);
    Setfile(s->text,Getfile(s->str));
    Setline(s->text,Getline(s->str));
    while (!done) {
	if ((c = nextchar(s)) == 0) return;
	if (c == '\\') c = nextchar(s);
	else if (c == '\n') done = 1;
    }
    return;
}
开发者ID:kanbang,项目名称:Colt,代码行数:14,代码来源:scanner.c


示例20: readlines

int readlines(char *lineptr[], int maxlines) {
	int len, nlines;
	char *p, line[MAXLEN];
	nlines = 0;
	while ((len = Getline(line, MAXLEN)) > 0)
		if (nlines >= maxlines || (p = alloc(len)) == NULL)
			return -1;
		else {
			line[len - 1] = '\0';
			strcpy(p, line);
			lineptr[nlines++] = p;
		}
	return nlines;
}
开发者ID:RuohengLiu,项目名称:learn-to-code,代码行数:14,代码来源:5-13-tail.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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