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

C++ GetLine函数代码示例

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

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



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

示例1: main

int main(int argc,char **argv)
{
  int curr_arg;
  bool bDebug;
  bool bVerbose;
  bool bHaveDateString;
  char *date_string;
  bool bGetDateFromCwd;
  bool bPosNeg;
  int retval;
  int offset;
  FILE *fptr;
  int linelen;
  int line_no;
  int number;
  int work;
  int total;
  int positive_total;
  int negative_total;

  if ((argc < 2) || (argc > 8)) {
    printf(usage);
    return 1;
  }

  bDebug = false;
  bVerbose = false;
  bHaveDateString = false;
  bGetDateFromCwd = false;
  bPosNeg = false;
  offset = 0;

  for (curr_arg = 1; curr_arg < argc; curr_arg++) {
    if (!strcmp(argv[curr_arg],"-debug"))
      bDebug = true;
    else if (!strcmp(argv[curr_arg],"-verbose"))
      bVerbose = true;
    else if (!strncmp(argv[curr_arg],"-offset",7))
      sscanf(&argv[curr_arg][7],"%d",&offset);
    else if (!strncmp(argv[curr_arg],"-date",5)) {
      date_string = &argv[curr_arg][5];
      bHaveDateString = true;
    }
    else if (!strcmp(argv[curr_arg],"-get_date_from_cwd"))
      bGetDateFromCwd = true;
    else if (!strcmp(argv[curr_arg],"-pos_neg"))
      bPosNeg = true;
    else
      break;
  }

  if (argc - curr_arg != 1) {
    printf(usage);
    return 2;
  }

  if (bHaveDateString && bGetDateFromCwd) {
    printf("can't specify both -date and -get_date_from_cwd\n");
    return 3;
  }

  if (bDebug || bGetDateFromCwd)
    getcwd(save_dir,_MAX_PATH);

  if (bGetDateFromCwd) {
    retval = get_date_from_cwd(save_dir,&date_string);

    if (retval) {
      printf("get_date_from_cwd() failed: %d\n",retval);
      return 4;
    }

    bHaveDateString = true;
  }

  if ((fptr = fopen(argv[curr_arg],"r")) == NULL) {
    printf(couldnt_open,argv[curr_arg]);
    return 5;
  }

  line_no = 0;
  total = 0;

  if (bPosNeg) {
    positive_total = 0;
    negative_total = 0;
  }

  for ( ; ; ) {
    GetLine(fptr,line,&linelen,MAX_LINE_LEN);

    if (feof(fptr))
      break;

    line_no++;

    sscanf(&line[offset],"%d %d",&number,&work);
    work *= number;

    total += work;
//.........这里部分代码省略.........
开发者ID:neostreet,项目名称:command_line_tools,代码行数:101,代码来源:add_multf_int.c


示例2: main

int main(int argc,char **argv)
{
  int m;
  int n;
  int curr_arg;
  bool bDebug;
  int player_name_ix;
  int player_name_len;
  FILE *fptr0;
  int filename_len;
  FILE *fptr;
  int line_len;
  int line_no;
  int ix;
  int file_no;

  if ((argc < 3) || (argc > 4)) {
    printf(usage);
    return 1;
  }

  bDebug = false;

  for (curr_arg = 1; curr_arg < argc; curr_arg++) {
    if (!strcmp(argv[curr_arg],"-debug")) {
      bDebug = true;
      getcwd(save_dir,_MAX_PATH);
    }
    else
      break;
  }

  if (argc - curr_arg != 2) {
    printf(usage);
    return 2;
  }

  player_name_ix = curr_arg++;
  player_name_len = strlen(argv[player_name_ix]);

  if ((fptr0 = fopen(argv[curr_arg],"r")) == NULL) {
    printf(couldnt_open,argv[curr_arg]);
    return 3;
  }

  file_no = 0;

  for ( ; ; ) {
    GetLine(fptr0,filename,&filename_len,MAX_FILENAME_LEN);

    if (feof(fptr0))
      break;

    file_no++;

    if ((fptr = fopen(filename,"r")) == NULL) {
      printf(couldnt_open,filename);
      continue;
    }

    line_no = 0;

    for ( ; ; ) {
      GetLine(fptr,line,&line_len,MAX_LINE_LEN);

      if (feof(fptr))
        break;

      line_no++;

      if (Contains(true,
        line,line_len,
        argv[player_name_ix],player_name_len,
        &ix)) {

        if (!strncmp(line,dealt_to,DEALT_TO_LEN)) {
          for (n = 0; n < line_len; n++) {
            if (line[n] == '[')
              break;
          }

          if (n < line_len) {
            n++;

            for (m = n; m < line_len; m++) {
              if (line[m] == ']')
                break;
            }

            if (m < line_len) {
              line[m] = 0;

              if (!bDebug)
                printf("%s\n",&line[n]);
              else
                printf("%s %s\\%s\n",&line[n],save_dir,filename);

              continue;
            }
          }
//.........这里部分代码省略.........
开发者ID:yawecodin,项目名称:misc_poker_utilities,代码行数:101,代码来源:fdealt_to3.c


示例3: PrintInstructions2

void PrintInstructions2()
{
	printf("\nThe Game is going to start . Press any key when you are ready.");
	GetLine();
	printf("\nTo pause,click mouse on the graph.\n");
}
开发者ID:jarvis-huang,项目名称:CPP,代码行数:6,代码来源:Darwin.c


示例4: PreviewSubTask

void PreviewSubTask()
#endif
{
#ifndef __PPC__
	struct SubTask *st;
#endif
	BOOL done = FALSE, working = FALSE, init = FALSE, stop = FALSE;
	int y;
	struct SubTaskMsg *stm;
	struct PreviewData *data;
	rsiSMALL_COLOR *line;

#ifndef __PPC__
	st = InitSubTask();
#endif
	if(st)
	{
		/*
		** after the sub task is up and running, we go into
		** a loop and process the messages from the main task.
		*/
		while(!done)
		{
			while((stm = (struct SubTaskMsg *)WARPOS_PPC_FUNC(GetMsg)(st->st_Port)))
			{
				switch(stm->stm_Command)
				{
					case STC_SHUTDOWN:
						// This is the shutdown message from KillSubTask().
						done = TRUE;
						working = FALSE;
						break;
					case STC_CLEANUP:
						working = FALSE;
						if(data->preview)
						{
#ifdef __MIXEDBINARY__
							PreviewDelete(data->preview);
#else
							delete data->preview;
#endif
							data->preview = NULL;
						}
						break;
					case STC_START:
						working = TRUE;
						stop = FALSE;
						init = FALSE;
						data = (struct PreviewData*)stm->stm_Parameter;
#ifdef __MIXEDBINARY__
						data->preview = PreviewCreate();
#else
						data->preview = new PREVIEW;
#endif
						if(!data->preview)
							done = TRUE;
						break;
					case STC_STOP:
						stop = TRUE;
						break;
					case STC_RESUME:
						stop = FALSE;
						break;
				}

				/*
				** If we received a shutdown message, we do not reply it
				** immediately. First, we need to free our resources.
				*/
				if(done)
					break;
				WARPOS_PPC_FUNC(ReplyMsg)((struct Message *)stm);
			}
			if(working && !stop)
			{
				if(!init)
				{
#ifdef __MIXEDBINARY__
					if(Init(data->preview, data->width, data->height, LINES, data->surf, data->object))
#else
					if(data->preview->Init(data->width, data->height, LINES, data->surf, data->object))
#endif
					{
						init = TRUE;
						DOMETHOD(app, MUIM_Application_PushMethod, data->msghandler, 4, MUIM_MsgHandler_PushMessage, data->renderarea, 1, MUIM_Render_ResetColors);
						DOMETHOD(app, MUIM_Application_PushMethod, data->msghandler, 6, MUIM_MsgHandler_PushMessage, data->renderarea, 3, MUIM_Set, MUIA_Render_SubTask, st);
#ifdef __MIXEDBINARY__
						DOMETHOD(app, MUIM_Application_PushMethod, data->msghandler, 6, MUIM_MsgHandler_PushMessage, data->renderarea, 3, MUIM_Set, MUIA_Render_Data, GetLine(data->preview));
#else
						DOMETHOD(app, MUIM_Application_PushMethod, data->msghandler, 6, MUIM_MsgHandler_PushMessage, data->renderarea, 3, MUIM_Set, MUIA_Render_Data, data->preview->GetLine());
#endif
						DOMETHOD(app, MUIM_Application_PushMethod, data->msghandler, 6, MUIM_MsgHandler_PushMessage, data->renderarea, 3, MUIM_Set, MUIA_Render_Lines, LINES);
						y = 0;
					}
					else
					{
						working = FALSE;
					}
				}

//.........这里部分代码省略.........
开发者ID:Kalamatee,项目名称:RayStorm,代码行数:101,代码来源:subtask.cpp


示例5: Kiface

void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event )
{
    FOOTPRINT_ALIAS_LIST aliases;
    FOOTPRINT_ALIAS*     alias;
    COMPONENT*           component;
    wxFileName           fn;
    wxString             msg, tmp;
    char                 Line[1024];
    FILE*                file;
    size_t               ii;

    SEARCH_STACK&        search = Kiface().KifaceSearch();

    if( m_netlist.IsEmpty() )
        return;

    // Find equivalents in all available files.
    for( ii = 0; ii < m_AliasLibNames.GetCount(); ii++ )
    {
        fn = m_AliasLibNames[ii];

        if( !fn.HasExt() )
        {
            fn.SetExt( FootprintAliasFileExtension );
            // above fails if filename has more than one point
        }
        else
        {
            fn.SetExt( fn.GetExt() + wxT( "." ) + FootprintAliasFileExtension );
        }

        tmp = search.FindValidPath( fn.GetFullPath() );

        if( !tmp )
        {
            msg.Printf( _( "Footprint alias library file '%s' could not be found in the "
                           "default search paths." ),
                        GetChars( fn.GetFullName() ) );
            wxMessageBox( msg, FMT_TITLE_LIB_LOAD_ERROR, wxOK | wxICON_ERROR );
            continue;
        }

        file = wxFopen( tmp, wxT( "rt" ) );

        if( file == NULL )
        {
            msg.Printf( _( "Error opening alias library '%s'." ), GetChars( tmp ) );
            wxMessageBox( msg, FMT_TITLE_LIB_LOAD_ERROR, wxOK | wxICON_ERROR );
            continue;
        }

        while( GetLine( file, Line, NULL, sizeof(Line) ) != NULL )
        {
            char* text = Line;
            wxString value, footprint, wtext = FROM_UTF8( Line );

            value = GetQuotedText( wtext );

            if( text == NULL || ( *text == 0 ) || value.IsEmpty() )
                continue;

            footprint = GetQuotedText( wtext );

            if( footprint.IsEmpty() )
                continue;

            value.Replace( wxT( " " ), wxT( "_" ) );

            alias = new FOOTPRINT_ALIAS();
            alias->m_Name = value;
            alias->m_FootprintName = footprint;
            aliases.push_back( alias );
        }

        fclose( file );
    }

    // Display the number of footprint aliases.
    msg.Printf( _( "%d footprint aliases found." ), aliases.size() );
    SetStatusText( msg, 0 );

    m_skipComponentSelect = true;
    ii = 0;

    for( unsigned kk = 0;  kk < m_netlist.GetCount();  kk++ )
    {
        component = m_netlist.GetComponent( kk );

        bool found = false;
        m_compListBox->SetSelection( ii++, true );

        if( !component->GetFPID().empty() )
            continue;

        BOOST_FOREACH( FOOTPRINT_ALIAS& alias, aliases )
        {

            if( alias.m_Name.CmpNoCase( component->GetValue() ) != 0 )
                continue;

//.........这里部分代码省略.........
开发者ID:danstiurca,项目名称:kicad-source-mirror,代码行数:101,代码来源:autosel.cpp


示例6: main

int main(int argc,char **argv)
{
  int m;
  int n;
  int p;
  int curr_arg;
  bool bDebug;
  bool bCount;
  bool bShowZero;
  int reupped_count;
  int player_name_ix;
  int player_name_len;
  FILE *fptr0;
  int filename_len;
  FILE *fptr;
  int line_len;
  int line_no;
  int dbg_line_no;
  int ix;
  int street;
  int num_street_markers;
  int starting_balance;
  int spent_this_street;
  int spent_this_hand;
  int end_ix;
  int uncalled_bet_amount;
  int collected_from_pot;
  int collected_from_pot_count;
  int ending_balance;
  int file_no;
  int dbg_file_no;
  int dbg;
  int work;
  double dwork1;
  double dwork2;
  bool bSkipping;

  if ((argc < 3) || (argc > 6)) {
    printf(usage);
    return 1;
  }

  bDebug = false;
  bCount = false;
  bShowZero = false;

  for (curr_arg = 1; curr_arg < argc; curr_arg++) {
    if (!strcmp(argv[curr_arg],"-debug"))
      bDebug = true;
    else if (!strcmp(argv[curr_arg],"-count"))
      bCount = true;
    else if (!strcmp(argv[curr_arg],"-show_zero")) {
      bShowZero = true;
      bCount = true;
    }
    else
      break;
  }

  if (argc - curr_arg != 2) {
    printf(usage);
    return 2;
  }

  player_name_ix = curr_arg++;
  player_name_len = strlen(argv[player_name_ix]);

  if ((fptr0 = fopen(argv[curr_arg],"r")) == NULL) {
    printf(couldnt_open,argv[curr_arg]);
    return 3;
  }

  file_no = 0;
  dbg_file_no = -1;

  for ( ; ; ) {
    GetLine(fptr0,filename,&filename_len,MAX_FILENAME_LEN);

    if (feof(fptr0))
      break;

    strcpy(prev_filename,filename);
    file_no++;

    if (dbg_file_no == file_no)
      dbg = 1;

    if ((fptr = fopen(filename,"r")) == NULL) {
      printf(couldnt_open,filename);
      continue;
    }

    line_no = 0;
    ending_balance = -1;
    reupped_count = 0;

    for ( ; ; ) {
      GetLine(fptr,line,&line_len,MAX_LINE_LEN);

      if (feof(fptr))
//.........这里部分代码省略.........
开发者ID:neostreet,项目名称:misc_poker_utilities,代码行数:101,代码来源:freupped3.c


示例7: Execute

DWORD WINAPI Execute(LPDWORD data)
{
	int i, linenumber;
	char line[256], buf[256], logbuf[100], *prog;
	BOOL error = FALSE;

	obj = NULL;
	light = NULL;

	ULONG arg[MAXARGS];

	for (i = 0; i < MAXARGS; i++)
		arg[i] = NULL;

	prog = ((THREAD_DATA *)data)->szProg;
	pDisplay = ((THREAD_DATA *)data)->pDisplay;
	strcpy(szIncludePath, "");
	strcpy(szPicturePath, "");

	err = rsiSetLogCB(Log);
	if (err)
	{
		rsiGetErrorMsg(buf,err);
		Log(buf);
	}

	err = rsiSetUpdateStatusCB(UpdateStatus);
	if (err)
	{
		rsiGetErrorMsg(buf,err);
		Log(buf);
	}

	err = rsiSetCheckCancelCB(CheckCancel);
	if (err)
	{
		rsiGetErrorMsg(buf,err);
		Log(buf);
	}

	err = rsiSetCooperateCB(Cooperate);
	if (err)
	{
		rsiGetErrorMsg(buf,err);
		Log(buf);
	}

	linenumber = 0;
	include = 0;

	while ((*prog || include > 0) && !error)
	{ 
		GetLine(&prog, line, &linenumber);
		// read command first
		if (!Scan(line, buf, arg))
		{
			i = 0;
			// find command in list	
  			while (commands[i].name && stricmp(buf, commands[i].name))
  		 		i++;
				
			// call corresponding function with "arg" as argument
			if (commands[i].func)
				error = commands[i].func(arg);
			else
				error = ERROR_UNKNOWNCOM;
				
			for (i = 0; i < MAXARGS; i++)
			{
				if (arg[i])
					delete (ULONG *)arg[i];
				arg[i] = NULL;
			}

			if (error)
			{
				if (include)
				{
					sprintf(logbuf, "In include file: \"%s\"", Includefile[include].name);
					pDisplay->Log(logbuf);
					linenumber = Includefile[include].linenumber;
				}
				sprintf(logbuf, "Error executing command in line %i", linenumber);
				pDisplay->Log(logbuf);
				pDisplay->Log(line);
				GetError(logbuf, error);
				pDisplay->Log(logbuf);
			}
		}
	}
	if (error)
	{
		pDisplay->Log("Error occurred");
		pDisplay->Log("Cancel execution");
		// close open include files
		while (include > 0)
		{
			if (Includefile[include].hFile)
				fclose(Includefile[include].hFile);
			include--;
//.........这里部分代码省略.........
开发者ID:Kalamatee,项目名称:RayStorm,代码行数:101,代码来源:parser.cpp


示例8: main


//.........这里部分代码省略.........
  if (bDelta && bStartingBalance) {
    printf("can't specify both -delta and -starting_balance\n");
    return 3;
  }

  player_name_ix = curr_arg++;
  player_name_len = strlen(argv[player_name_ix]);

  if ((fptr0 = fopen(argv[curr_arg],"r")) == NULL) {
    printf(couldnt_open,argv[curr_arg]);
    return 4;
  }

  ending_balance = -1;
  prev_ending_balance = -1;

  if (bDelta) {
    max_delta = -1;
    min_delta = 1;
  }
  else if (bStartingBalance) {
    max_starting_balance = -1;
    min_starting_balance = 1;
  }
  else {
    max_ending_balance = -1;
    min_ending_balance = 1;
  }

  file_no = 0;
  dbg_file_no = -1;

  for ( ; ; ) {
    GetLine(fptr0,filename,&filename_len,MAX_FILENAME_LEN);

    if (feof(fptr0))
      break;

    file_no++;

    if (dbg_file_no == file_no)
      dbg = 1;

    if ((fptr = fopen(filename,"r")) == NULL) {
      printf(couldnt_open,filename);
      continue;
    }

    line_no = 0;
    street = 0;
    num_street_markers = 0;
    ante = 0;
    bring_in = 0;
    spent_this_street = 0;
    spent_this_hand = 0;
    uncalled_bet_amount = 0;
    collected_from_pot = 0;
    collected_from_pot_count = 0;

    for ( ; ; ) {
      GetLine(fptr,line,&line_len,MAX_LINE_LEN);

      if (feof(fptr))
        break;

      line_no++;
开发者ID:neostreet,项目名称:misc_poker_utilities,代码行数:67,代码来源:fhand_bal.c


示例9: IsFunctioning

//=====================================================================
bool Rowind::IsFunctioning() {
	if(GetLine() != Null) {
		return true;
	}
	return false;
}
开发者ID:bobalong,项目名称:Rowind,代码行数:7,代码来源:Rowind.cpp


示例10: read_ozone

int read_ozone(char* fname, short int** out_data, int* doy, int* year, int* nlats,
               int* nlons, float* minlat, float* minlon, float* maxlat,
               float* maxlon, float* latsteps, float* lonsteps,
               float* lat_array, float* lon_array)
{ 
 FILE *fp;
 char line[MAX_STR_LEN+1];
 char dtype[10],month[4],valbuf[4];
 char c_day_of_month[3];
 int day_of_month;
 int irow,icol,i=0,ival;
 int ilat;
 int number;
 short int* data;
 float mylat;
 float comp_lat,comp_lon;
 char hemisphere1, hemisphere2;
 /*
 Day: 260 Sep 17, 2001    EP/TOMS    NRT OZONE    GEN:01.271 Asc LECT: 11:09 AM 
012345678 1 2345678 2 2345678 3 2345678 4 2345678 5 2345678 6 2345678 7 2345678
 Longitudes:  288 bins centered on 179.375 W to 179.375 E  (1.25 degree steps)  
 Latitudes :  180 bins centered on  89.5   S to  89.5   N  (1.00 degree steps)  
 */

 fp = fopen(fname, "r");
 GetLine(fp,line);
 sscanf(line," Day: %3d ",doy);
 strncpy(month,&line[10],3); month[3]='\0';
 strncpy(c_day_of_month,&line[14],2); c_day_of_month[2]='\0';
 strncpy(dtype,&line[26],7); dtype[7]='\0';
 day_of_month= atoi( c_day_of_month );
 *year= atoi( &line[18] );
 printf("year=%d month=%s day_of_month=%d\n",*year,month,day_of_month);

 GetLine(fp,line);
 sscanf(line," Longitudes:  %3d bins centered on %7f W to %7f E  (%5f ", 
        nlons, minlon, maxlon, lonsteps);
 /* OMI data used different index - Feng */
 if(strstr(fname, "omi")) {
   hemisphere1= line[42];  hemisphere2= line[55];  
 }
 else {
 hemisphere1= line[43];  hemisphere2= line[56];
 } 
 *minlon *= (hemisphere1=='S'||hemisphere1=='W'?-1.0:1.0);
 *maxlon *= (hemisphere2=='S'||hemisphere2=='W'?-1.0:1.0);

 GetLine(fp,line);
 sscanf(line," Latitudes :  %3d bins centered on %7f S to %7f N  (%4f ",
        nlats, minlat, maxlat, latsteps);
 /* OMI data used different index - Feng */
 if(strstr(fname, "omi")) {
   hemisphere1= line[42];  hemisphere2= line[55];  
 }
 else {
 hemisphere1= line[43];  hemisphere2= line[56]; 
 }
 *minlat *= (hemisphere1=='S'||hemisphere1=='W'?-1.0:1.0);
 *maxlat *= (hemisphere2=='S'||hemisphere2=='W'?-1.0:1.0);

 comp_lat= *minlat;
 comp_lon= *minlon;

 data = (short int *)calloc(((*nlats)*(*nlons)), sizeof(short int));

 for (icol=0; icol<*nlons; icol++)
   {
   lon_array[icol]= comp_lon;
   comp_lon += *lonsteps;
   } 

 ilat=0;
 for (irow=0; irow<*nlats; irow++)
 {
   ival=0;
   for (icol=0; icol<NLINE; icol++)
     {
     GetLine(fp,line);
     for ( i=0; i<(icol<(NLINE-1)?longline:shortline); i++ )
       {
       
       strncpy(valbuf,&line[i*3+1],3);
       valbuf[3]='\0';
       sscanf(valbuf,"%3d",&number); 
       data[(*nlats-ilat-1)*(*nlons)+ival++]= number;
       /*
       sscanf(&line[i*3+1],"%3d",&data[ival++]);
       */
       }
     }
   sscanf(&line[i*3+1],"   lat =   %f",&mylat);
   if (0 )   printf("*** in=(%s) mylat=(%f) complat=(%f) ***\n",&line[i*3+1],mylat,comp_lat);
   lat_array[*nlats-ilat-1]= comp_lat;
   comp_lat += *latsteps;
   ilat++;
 }

 *out_data= data;
 return 0;
}
开发者ID:Jwely,项目名称:ledaps,代码行数:100,代码来源:convert_ozone.c


示例11: main

void main(void)
{	
	M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts
	M8C_EnableIntMask(INT_MSK1, INT_MSK1_DBB01); // Enable DBB01 Interrupt for TempCounter
	M8C_EnableIntMask(INT_MSK1, INT_MSK1_DBB11); // Enable DBB01 Interrupt for MotorDriver
	M8C_EnableIntMask(INT_MSK0, INT_MSK0_GPIO); // Enable GPIO interrupt for Tout
	
	// Start the UART(with no parity), LCD, TempCounter and MotorDriver
	UART_Start(UART_PARITY_NONE);
	LCD_Start();
	TempCounter_EnableInt(); // Enable interrupts for counter
	TempCounter_Start();
	MotorDriver_EnableInt(); // Enable interrupts for counter
	
	// Start I2CHW
	I2CHW_Start();
	I2CHW_EnableMstr();
	I2CHW_EnableInt();
	
	WriteI2C(slaveAddress, 0xAC, 1, 0x02); // Write to access config, sets mode to cooling(POL = 1), also turns 1-SHOT off, continuous conversions
	
	WriteI2C(slaveAddress, 0xA1, 2, (setTemp + tolerance), 0x00); // Sets initial high temp to be setTemp + tolerance
	WriteI2C(slaveAddress, 0xA2, 2, (setTemp - tolerance), 0x00); // Sets initial low temp to be setTemp - tolerance
	WriteI2C(slaveAddress, 0xEE, 0); // This tells the temperature IC to start converting the temperatures
	
	// Writes initial string to LCD. When LCD is updated, only the numbers will be changed
	LCD_Position(0,0); LCD_PrCString("CUR: 00 OFF     ");
	LCD_Position(1,0); LCD_PrCString("SET: 00 FAN OFF ");
	
	// This is the command usage string
	UART_CPutString("#################### Heating/Cooling Stepper Motors ##################\r\n\
#	S ##\r\n\
#		S - Set the desired Temperature\r\n\
#		## - Desired temperature in celsius\r\n\
#\r\n\
#	T ##\r\n\
#		T - Set the desired tolerance\r\n\
#		## - Desired tolerance in celsius\r\n\
#\r\n\
#	M X\r\n\
#		M - Change the mode of the thermostat\r\n\
#		X - C is for cool, H is for heat, F is for off\r\n\
#\r\n\
#	F X S\r\n\
#		F - Change the mode of the fan\r\n\
#		X - A is for automatic fan control, M is for always on\r\n\
#		S - Speed of the fan, H = high, M = medium, L = low\r\n\
#####################################################################\r\n");
	while (1)
	{
		char *cmd;
		char *params;
		
		if (GetLine(buf, &strPos, 79)) // Only process the data if GetLine returns true
		{
			cmd = Lowercase(cstrtok(buf, " ")); // Lowercase the first word from the inputted string
			
			if (strlen(cmd) == 1 && cmd[0] == 's') // If the person entered s
			{	
				int temp;
			
				params = cstrtok(0x00, " "); // Read next word 							
				// If next word isnt number or isnt 1 or 2 characters long, then return error
				if (!IsNumber(params) || strlen(params) < 1 || strlen(params) > 2 || csscanf(params, "%d", &temp) != 1) goto error;
				
				// If there is additional data at end of string or if number is not within 0-99, return error
				if (cstrtok(0x00, " ") != 0x00) goto error;
				if ( temp > 99 || temp < 0) goto error; 
				
				setTemp = temp;
				WriteI2C(slaveAddress, 0xA1, 2, (setTemp + tolerance), 0x00); // Sets high temp to be setTemp + tolerance
				WriteI2C(slaveAddress, 0xA2, 2, (setTemp - tolerance), 0x00); // Sets low temp to be setTemp - tolerance
				updateLCD = TRUE; // Update the LCD
			}
			else if (strlen(cmd) == 1 && cmd[0] == 't') // If the person entered t
			{	
				int tol; 
			
				params = cstrtok(0x00, " "); // Read next word					
				// If next word isnt number or isnt 1 or 2 characters long, then return error
				if (!IsNumber(params) || strlen(params) < 1 || strlen(params) > 2 || csscanf(params, "%d", &tol) != 1) goto error;
				
				// If there is additional data at end of string or if number is not within 0-10, return error
				if (cstrtok(0x00, " ") != 0x00) goto error;
				if (tol < 0 || tol > 10) goto error;
				
				tolerance = tol;
				
				WriteI2C(slaveAddress, 0xA1, 2, (setTemp + tolerance), 0x00); // Sets high temp to be setTemp + tolerance
				WriteI2C(slaveAddress, 0xA2, 2, (setTemp - tolerance), 0x00); // Sets low temp to be setTemp - tolerance
				updateLCD = TRUE; // Update the LCD
				
			}
			else if (strlen(cmd) == 1 && cmd[0] == 'm') // If the person entered m
			{	
				char mode;
			
				params = cstrtok(0x00, " "); // Read next word
				
				// If next word isnt 1 character long, return error
//.........这里部分代码省略.........
开发者ID:addisonElliott,项目名称:ECE381,代码行数:101,代码来源:main.c


示例12: main

int main(int argc,char **argv)
{
  int m;
  int n;
  bool bNoSort;
  bool bNot;
  int curr_arg;
  FILE *fptr;
  int line_len;
  int num_sessions;
  int session_ix;
  int delta;
  int session_is_blue;
  int prev_session_is_blue;
  int chara;
  int *sort_ixs;
  int num_blue_streaks;
  int blue_streak_ix;
  int retval;
  char *cpt;
  int cumulative_delta;
  int max_cumulative_delta;

  if ((argc < 2) || (argc > 5)) {
    printf(usage);
    return 1;
  }

  bNoSort = false;
  bAscending = false;
  bNot = false;

  for (curr_arg = 1; curr_arg < argc; curr_arg++) {
    if (!strcmp(argv[curr_arg],"-no_sort"))
      bNoSort = true;
    else if (!strcmp(argv[curr_arg],"-ascending"))
      bAscending = true;
    else if (!strcmp(argv[curr_arg],"-not"))
      bNot = true;
    else
      break;
  }

  if (argc - curr_arg != 1) {
    printf(usage);
    return 2;
  }

  if ((fptr = fopen(argv[curr_arg],"r")) == NULL) {
    printf(couldnt_open,argv[curr_arg]);
    return 3;
  }

  num_sessions = 0;
  num_blue_streaks = 0;
  cumulative_delta = 0;
  max_cumulative_delta = 0;

  for ( ; ; ) {
    GetLine(fptr,line,&line_len,MAX_LINE_LEN);

    if (feof(fptr))
      break;

    if (!line_len)
      continue;

    chara = line[0];

    if (((chara >= 'a') && (chara <= 'z')) ||
        ((chara >= 'A') && (chara <= 'Z')))
      continue;

    sscanf(&line[11],"%d",&delta);

    cumulative_delta += delta;

    if (cumulative_delta > max_cumulative_delta) {
      if (!bNot)
        session_is_blue = 1;
      else
        session_is_blue = 0;

      max_cumulative_delta = cumulative_delta;
    }
    else {
      if (!bNot)
        session_is_blue = 0;
      else
        session_is_blue = 1;
    }

    if ((session_is_blue == 1) && ((num_sessions == 0) || (prev_session_is_blue == 0)))
      num_blue_streaks++;

    num_sessions++;
    prev_session_is_blue = session_is_blue;
  }

  if ((session_info = (struct session_info_struct *)malloc(
//.........这里部分代码省略.........
开发者ID:neostreet,项目名称:misc_poker_utilities,代码行数:101,代码来源:session_blue_streaks.c


示例13: ParseInput

int
ParseInput(register DviWidget dw)
{
	int		n, k;
	int		c;
	char		Buffer[BUFSIZ];
	int		NextPage;
	int		otherc;

	StopSeen = 0;

	/*
	 * make sure some state exists
	 */

	if (!dw->dvi.state)
	    push_env (dw);
	for (;;) {
		switch (DviGetC(dw, &c)) {
		case '\n':	
			break;
		case ' ':	/* when input is text */
		case 0:		/* occasional noise creeps in */
			break;
		case '{':	/* push down current environment */
			push_env(dw);
			break;
		case '}':
			pop_env(dw);
			break;
		/*
		 * two motion digits plus a character
		 */
		case '0': case '1': case '2': case '3': case '4':
		case '5': case '6': case '7': case '8': case '9':
			HorizontalMove(dw, (c-'0')*10 +
					   DviGetC(dw,&otherc)-'0');
			/* fall through */
		case 'c':	/* single ascii character */
			DviGetC(dw,&c);
		    	if (c == ' ')
			    break;
			Buffer[0] = c;
			Buffer[1] = '\0';
			(void) PutCharacter (dw, Buffer);
			break;
		case 'C':
			GetWord (dw, Buffer, BUFSIZ);
			(void) PutCharacter (dw, Buffer);
			break;
		case 't':
			Buffer[1] = '\0';
			while (DviGetC (dw, &c) != EOF
			       && c != ' ' && c != '\n') {
				Buffer[0] = c;
				HorizontalMove (dw, PutCharacter (dw, Buffer));
			}
			break;
		case 'u':
			n = GetNumber(dw);
			Buffer[1] = '\0';
			while (DviGetC (dw, &c) == ' ')
				;
			while (c != EOF && c != ' ' && c != '\n') {
				Buffer[0] = c;
				HorizontalMove (dw,
						PutCharacter (dw, Buffer) + n);
				DviGetC (dw, &c);
			}
			break;

		case 'D':	/* draw function */
			(void) GetLine(dw, Buffer, BUFSIZ);
			if (dw->dvi.display_enable)
				ParseDrawFunction(dw, Buffer);
			break;
		case 's':	/* ignore fractional sizes */
			n = GetNumber(dw);
			dw->dvi.state->font_size = n;
			break;
		case 'f':
			n = GetNumber(dw);
			dw->dvi.state->font_number = n;
			break;
		case 'H':	/* absolute horizontal motion */
			k = GetNumber(dw);
			HorizontalGoto(dw, k);
			break;
		case 'h':	/* relative horizontal motion */
			k = GetNumber(dw);
			HorizontalMove(dw, k);
			break;
		case 'w':	/* word space */
			Word (dw);
			break;
		case 'V':
			n = GetNumber(dw);
			VerticalGoto(dw, n);
			break;
		case 'v':
//.........这里部分代码省略.........
开发者ID:0xffffffRabbit,项目名称:NextBSD-1,代码行数:101,代码来源:parse.c


示例14: main

int main(int argc,char **argv)
{
  int curr_arg;
  bool bVerbose;
  int ge_val;
  FILE *fptr;
  int line_len;
  int line_no;
  int last_ge_line_no;
  int val;
  int intervening;
  int max_intervening;

  if ((argc < 3) || (argc > 4)) {
    printf(usage);
    return 1;
  }

  bVerbose = false;

  for (curr_arg = 1; curr_arg < argc; curr_arg++) {
    if (!strcmp(argv[curr_arg],"-verbose"))
      bVerbose = true;
    else
      break;
  }

  if (argc - curr_arg != 2) {
    printf(usage);
    return 2;
  }

  sscanf(argv[curr_arg],"%d",&ge_val);

  if ((fptr = fopen(argv[curr_arg+1],"r")) == NULL) {
    printf(couldnt_open,argv[curr_arg+1]);
    return 3;
  }

  line_no = 0;
  last_ge_line_no = 0;
  max_intervening = 0;

  for ( ; ; ) {
    GetLine(fptr,line,&line_len,MAX_LINE_LEN);

    if (feof(fptr))
      break;

    line_no++;

    sscanf(line,"%d",&val);

    if (val >= ge_val) {
      if (!bVerbose)
        printf("%d\n",val);
      else if (!last_ge_line_no)
        printf("%s %d\n",line,line_no);
      else {
        intervening = line_no - (last_ge_line_no + 1);

        if (intervening > max_intervening)
          max_intervening = intervening;

        printf("%s %d (%d)\n",line,line_no,intervening);
      }

      last_ge_line_no = line_no;
    }
  }

  fclose(fptr);

  printf("max_intervening = %d\n",max_intervening);

  return 0;
}
开发者ID:neostreet,项目名称:misc_poker_utilities,代码行数:77,代码来源:delta_ge.c


示例15: main

int main(int argc,char **argv)
{
  FILE *fptr;
  int line_len;
  int line_no;
  int val;
  int max_nonzero_streak;
  int max_nonzero_streak_start_ix;
  int curr_nonzero_streak;
  int curr_nonzero_streak_start_ix;

  if (argc != 2) {
    printf(usage);
    return 1;
  }

  if ((fptr = fopen(argv[1],"r")) == NULL) {
    printf(couldnt_open,argv[1]);
    return 2;
  }

  line_no = 0;
  max_nonzero_streak = 0;
  curr_nonzero_streak = 0;


  for ( ; ; ) {
    GetLine(fptr,line,&line_len,MAX_LINE_LEN);

    if (feof(fptr))
      break;

    sscanf(line,"%d",&val);

    if (!val) {
      if (curr_nonzero_streak > max_nonzero_streak) {
        max_nonzero_streak = curr_nonzero_streak;
        max_nonzero_streak_start_ix = curr_nonzero_streak_start_ix;
      }

      curr_nonzero_streak = 0;
    }
    else {
      if (!curr_nonzero_streak)
        curr_nonzero_streak_start_ix = line_no;

      curr_nonzero_streak++;
    }

    line_no++;
  }

  if (curr_nonzero_streak > max_nonzero_streak) {
    max_nonzero_streak = curr_nonzero_streak;
    max_nonzero_streak_start_ix = curr_nonzero_streak_start_ix;
  }

  fclose(fptr);

  printf("%d (%d)\n",max_nonzero_streak,max_nonzero_streak_start_ix+1);

  return 0;
}
开发者ID:neostreet,项目名称:command_line_tools,代码行数:63,代码来源:max_nonzero_streak.c


示例16: switch


//.........这里部分代码省略.........
				AutoCompleteInsertText();
				AutoCompleteHide();
				return;
			}
			case VK_LEFT:		// left arrow
			case VK_RIGHT:		// right arrow
			case VK_INSERT:		// insert key
			case VK_DELETE: {	// delete key
				return;
			}
		}
	}

	BracedSectionHide();

	switch( nKey ) {
		case VK_TAB: {		// multi-line tabs
			long selStart, selEnd;

			GetSel( selStart, selEnd );

			// if multiple lines are selected add tabs to, or remove tabs from all of them
			if ( selEnd > selStart ) {
				CString text;

				text = GetSelText();

				if ( GetAsyncKeyState( VK_SHIFT ) & 0x8000 ) {
					if ( idStr::CharIsTab( text[0] ) ) {
						text.Delete( 0, 1 );
					}
					for ( int i = 0; i < text.GetLength() - 2; i++ ) {
						if ( idStr::CharIsNewLine( text[i] ) ) {
							do {
								i++;
							} while( idStr::CharIsNewLine( text[i] ) );
							if ( idStr::CharIsTab( text[i] ) ) {
								text.Delete( i, 1 );
							}
						}
					}
				} else {
					text.Insert( 0, '\t' );
					for ( int i = 0; i < text.GetLength() - 1; i++ ) {
						if ( idStr::CharIsNewLine( text[i] ) ) {
							do {
								i++;
							} while( idStr::CharIsNewLine( text[i] ) );
							text.Insert( i, '\t' );
						}
					}
				}

				ReplaceSel( text, TRUE );
				SetSel( selStart, selStart + text.GetLength() );
			} else {
				ReplaceSel( "\t", TRUE );
			}
			return;
		}
		case VK_RETURN: {	// auto-indentation
			long selStart, selEnd;
			int line, length, numTabs, i;
			char buffer[1024];
			idStr text;

			GetSel( selStart, selEnd );
			line = LineFromChar( selStart );
			length = GetLine( line, buffer, sizeof( buffer ) );
			for ( numTabs = 0; numTabs < length; numTabs++ ) {
				if ( !idStr::CharIsTab( buffer[numTabs] ) ) {
					break;
				}
			}
			bool first = true;
			for ( i = numTabs; i < length; i++ ) {
				if ( buffer[i] == '{' ) {
					numTabs++;
					first = false;
				} else if ( buffer[i] == '}' && !first ) {
					numTabs--;
				}
			}
			text = "\r\n";
			for ( i = 0; i < numTabs; i++ ) {
				text.Append( '\t' );
			}
			ReplaceSel( text, TRUE );
			return;
		}
	}

	m_TextDoc->Freeze( NULL );

	CRichEditCtrl::OnKeyDown( nKey, nRepCnt, nFlags );

	UpdateVisibleRange();

	m_TextDoc->Unfreeze( NULL );
}
开发者ID:RobertBeckebans,项目名称:fhDOOM,代码行数:101,代码来源:CSyntaxRichEditCtrl.cpp


示例17: LinkComp

Component* LinkComp::Copy () { 
    LinkComp* copy = new LinkComp((Line*) GetLine()->Copy());
    
    *copy->GetGraphic() = *GetGraphic();
    return copy;
}
开发者ID:barak,项目名称:ivtools-cvs,代码行数:6,代码来源:link.c


示例18: AutoCompleteUpdate

/*
================
CSyntaxRichEditCtrl::OnChar
================
*/
void CSyntaxRichEditCtrl::OnChar( UINT nChar, UINT nRepCnt, UINT nFlags ) {

	if ( nChar == VK_TAB ) {
		return;	// tab is handle in OnKeyDown
	}

	CRichEditCtrl::OnChar( nChar, nRepCnt, nFlags );

	// if the auto-complete list box is up
	if ( autoCompleteStart >= 0 ) {
		long selStart, selEnd;

		if ( charType[nChar] == CT_NAME ) {
			AutoCompleteUpdate();
			return;
		} else if ( nChar == VK_BACK ) {
			GetSel( selStart, selEnd );
			if ( selStart > autoCompleteStart ) {
				AutoCompleteUpdate();
			} else {
				AutoCompleteHide();
			}
			return;
		} else {
			AutoCompleteHide();
		}
	}

	// if the function parameter tool tip is up
	if ( funcParmToolTipStart >= 0 ) {
		long selStart, selEnd;

		if ( nChar == ')' || nChar == VK_ESCAPE ) {
			ToolTipHide();
		} else if ( nChar == VK_BACK ) {
			GetSel( selStart, selEnd );
			if ( selStart < funcParmToolTipStart ) {
				ToolTipHide();
			}
		}
	}

	// show keyword auto-completion
	if ( keyWordAutoCompletion && charType[nChar] == CT_NAME && funcParmToolTipStart < 0 ) {
		long selStart, selEnd;
		int line, column, length, i;
		char buffer[1024];

		GetSel( selStart, selEnd );
		line = LineFromChar( selStart );
		length = GetLine( line, buffer, sizeof( buffer ) );
		column = selStart - LineIndex( line );
		if ( column <= 1 || charType[buffer[column-2]] == CT_WHITESPACE ) {
			if ( column >= length-1 || charType[buffer[column]] == CT_WHITESPACE ) {

				autoCompleteListBox.ResetContent();
				for ( i = 0; keyWords[i].keyWord; i++ ) {
					autoCompleteListBox.AddString( keyWords[i].keyWord );
				}
				AutoCompleteShow( selStart - 1 );
			}
		}
		return;
	}

	// highlight braced sections
	if ( nChar == '{' ) {
		BracedSectionStart( '{', '}' );
	} else if ( nChar == '}' ) {
		BracedSectionEnd( '{', '}' );
	} else if ( nChar == '(' ) {
		BracedSectionStart( '(', ')' );
	} else if ( nChar == ')' ) {
		BracedSectionEnd( '(', ')' );
	} else if ( nChar == '[' ) {
		BracedSectionStart( '[', ']' );
	} else if ( nChar == ']' ) {
		BracedSectionEnd( '[', ']' );
	} else if ( nChar == '<' ) {
		BracedSectionStart( '<', '>' );
	} else if ( nChar == '>' ) {
		BracedSectionEnd( '<', '>' );
	}

	// show object member auto-completion
	if ( nChar == '.' && GetObjectMembers && funcParmToolTipStart < 0 ) {
		int charIndex;
		CString name;

		if ( GetNameBeforeCurrentSelection( name, charIndex ) ) {
			autoCompleteListBox.ResetContent();
			if ( GetObjectMembers( name, autoCompleteListBox ) ) {
				AutoCompleteShow( charIndex );
			}
		}
//.........这里部分代码省略.........
开发者ID:RobertBeckebans,项目名称:fhDOOM,代码行数:101,代码来源:CSyntaxRichEditCtrl.cpp


示例19: GetCurrentLine

inline
screenline_t* GetCurrentLine() {
    return GetLine(cur_ln);
}
开发者ID:OmniBus,项目名称:hkday-pttbbs,代码行数:4,代码来源:screen.c


示例20: while

while(!infile.eof()){
	line = GetLine(&infile);
	
	var = line.Left(line.Find("="));
	val = line.Right(line.GetLength() - line.Find("=") - 1);
	
	if(line.IsEmpty() || line[0] == '[' || val.IsEmpty())
		;
	else if(var == "pallete"){
		long double en;
		m_Calculator.StringToDecimal(val, 10, en);
		m_CurrentPalete = (PaleteE)int(en);
	}		
	else if(var == "sound"){
		if(val == "1")
			m_SndEffects = true;
		else
			m_SndEffects = false;
	}		
	else if(var == "tooltips"){
		if(val == "1")
			m_ToolTips.On(true);
		else
			m_ToolTips.On(false);
	}		
	else if(var == "longoutput"){
		if(val == "1")
			m_OutputV.m_LongOutput = true;
		else
			m_OutputV.m_LongOutput = false;
	}
开发者ID:fallen2stealth,项目名称:GraphCalc-Update,代码行数:31,代码来源:Read.cpp



注:本文中的GetLine函数示例由纯净天空整理自Github/MSDocs等源码及文档管理


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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