コード例 #1
0
ファイル: memcorrupt.cpp プロジェクト: Junch/debug
int __cdecl wmain (int argc, WCHAR* args[])
{
    wint_t iChar = 0 ;
    g_AppInfo = new CAppInfo(L"Memory Corruption Sample", L"1.0" );
    if(!g_AppInfo)
    {
        return 1;
    }

    wprintf(L"Press: \n");
    wprintf(L"    1    To display application information\n");
    wprintf(L"    2    To simulated memory corruption\n");
    wprintf(L"    3    To exit\n\n\n>");

    while((iChar=_getwche())!='3')
    {
        switch(iChar)
        {
            case '1':
               g_AppInfo->PrintAppInfo();
               break;

            case '2':
              SimulateMemoryCorruption();
              wprintf(L"\nMemory Corruption completed\n");
              break;

            default:
              wprintf(L"\nInvalid option\n");
        }
        wprintf(L"\n\n> ");
    }
    return 0;
}
コード例 #2
0
ファイル: msvcrtmodule.c プロジェクト: ARK4579/cpython
static wchar_t
msvcrt_getwche_impl(PyModuleDef *module)
/*[clinic end generated code: output=3693cf78e3ea0cf6 input=49337d59d1a591f8]*/
{
    wchar_t ch;

    Py_BEGIN_ALLOW_THREADS
    ch = _getwche();
    Py_END_ALLOW_THREADS
    return ch;
}
コード例 #3
0
static PyObject *
msvcrt_getwche(PyObject *self, PyObject *args)
{
	Py_UNICODE ch;
	Py_UNICODE s[1];

	if (!PyArg_ParseTuple(args, ":getwche"))
		return NULL;

	Py_BEGIN_ALLOW_THREADS
	ch = _getwche();
	Py_END_ALLOW_THREADS
	s[0] = ch;
	return PyUnicode_FromUnicode(s, 1);
}
コード例 #4
0
ファイル: Source.c プロジェクト: jhKang1313/typing_practice
int Short_sentence_practice(wchar_t** Short_sentence,int sentence_Count)
{
	wchar_t Example_sentence[50];		//ªÀº±Û ¿¹½Ã¹® ±æÀÌ´Â ÃÖ´ë 50¹®ÀÚ
	wchar_t typing_One_word[50] = L"";	//»ç¿ëÀÚ ¹®ÀÚ ÀÔ·Â º¯¼ö
	wchar_t temp[50] = L"";
	wchar_t tmp[500];
	double typing_start_Time,typing_finish_Time;
	double typing_duration_Time;
	int start_Typing=1,present = 0,correct_word_Count =0;	//start_typingÀÌ 0À̸é ÀԷ½ÃÀÛ
	int len_Example_sentence ;
	int X_Cursor = 0;
	int Y_Cursor = 10;
	int i;
	int Highest_Typist = 0;
	int User_input_typist;
	long long Typist = 0;
	int typing_Accuracy = 0;
	int sentence_word_Count;
	int Check_accuracy[100] = {-1,};	//-1ÀÌ¸é ¹«ÀÔ·Â »óÅÂ, -2ÀÌ¸é ¸Â´Â ÀÔ·Â, ´Ù¸¥°ªÀ¸¸Â
//	int sentence_Count;
	int Random;
//	wchar_t** Short_sentence = NULL;
	setlocale(LC_ALL, "Korean");
	
//	Short_sentence = include_short_sentence(&sentence_Count,Short_practice);
	
	while(1)
	{
		Record_set(&start_Typing,&X_Cursor,&present,Check_accuracy,typing_One_word,Example_sentence);	//µ¥ÀÌÅÍ°ª ÃʱâÈ­
		UI_Short_prac(&Highest_Typist,&Typist,&typing_Accuracy);				//UI»Ñ¸®±â
		
		srand((unsigned)time(0));			
		Random = rand()%sentence_Count;		//ªÀº±Û ·£´ýÀ¸·Î °í¸£±â
		wcscpy(Example_sentence,Short_sentence[Random]);	
		len_Example_sentence = wcslen(Example_sentence);
		
		while(1)	//±ä±Û °Ë»çÇϴ°Ͱú µ¿ÀÏ
		{
			
			if(present>=len_Example_sentence-1)
			{
				typing_finish_Time = (double)(clock())/CLOCKS_PER_SEC;
				break;
			}
			gotoxy(5,Y_Cursor-3);
			for(i = 0 ; i < len_Example_sentence ; i++)
			{
				if(Check_accuracy[i] == i)
				{
					RED;
				}
				else if(Check_accuracy[i] == -2)
				{
					COROL;
				}
				else
				{
					WHITE;
				}
				printf("%C",Example_sentence[i]);
			}
	
			gotoxy(X_Cursor+5,Y_Cursor);
			typing_One_word[present] = _getwche();
			if(typing_One_word[present] == 27)
			{
				break;
			}
			if(typing_One_word[present] == 8 && present == 0)
				gotoxy(X_Cursor+5,Y_Cursor);
			else if(typing_One_word[present] == 8)
			{
				if(present>=1)
				{
					if(Example_sentence[present-1] < 256)
					{
						present--;
						X_Cursor-=1;
						gotoxy(X_Cursor+5,Y_Cursor);
						printf(" ");
					}
					else
					{
						present--;
						X_Cursor-=2;
						gotoxy(X_Cursor+5,Y_Cursor);
						printf("  ");
					}
				}
				Check_accuracy[present] = -1;
			}
			else if(typing_One_word[present] != Example_sentence[present])  //¿¹½Ã¹®À̶û ´Ù¸¦°æ¿ì
			{
				if(present== 0 && start_Typing == 1)
				{
					start_Typing = 0 ;
					typing_start_Time = (double)(clock())/CLOCKS_PER_SEC;
				}
				if(typing_One_word[present] <256 && Example_sentence[present] <256)
				{
					X_Cursor+=1;
					Check_accuracy[present] = present;
				}
				else if(typing_One_word[present] > 256 && Example_sentence[present] <256)
				{
					if(Example_sentence[present+1] < 256)
					{
						Check_accuracy[present] = present;
						Check_accuracy[present+1] = present+1;
						X_Cursor+= 2;
						present++;
					}
					else
					{
						X_Cursor+= 3;
						Check_accuracy[present] = present;
						Check_accuracy[present+1] = present+1;
						present++;
					}
				}
				else if(typing_One_word[present] < 256 && Example_sentence[present] > 256)
				{
					X_Cursor+= 2;
					Check_accuracy[present] = present;
				}
				else if(typing_One_word[present] >256 && Example_sentence[present] > 256)
				{
					X_Cursor+= 2;
					Check_accuracy[present] = present;
				}
				present++;
			}
			else  //¿¹½Ã¹®À̶û °°°Ô ÀÔ·Â
			{
				if(present== 0 && start_Typing == 1)
				{
					start_Typing = 0 ;
					typing_start_Time = (double)(clock())/CLOCKS_PER_SEC;
				}
				if(typing_One_word[present] < 256)
				{
					Check_accuracy[present] = -2;
					X_Cursor+= 1;
				}
				else
				{
					Check_accuracy[present] = -2;
					X_Cursor+=2;
				}
				present++;
			}
		}
		correct_word_Count = 0;
		if(typing_One_word[present] == 27)
			break;
		for(i = 0 ; i <= len_Example_sentence ; i++)
		{
			if(typing_One_word[i] == Example_sentence[i])		//»ç¿ëÀÚ°¡ ÀÔ·ÂÇÑ ¹®ÀÚ¿Í ¿¹½Ã¹®ÀÇ ¹®ÀÚ¿Í ¸Â´Â ±ÛÀڷθ¸ »õ·Î¿î ¹®ÀÚ¿­ »ý¼º
			{
				temp[correct_word_Count] = Example_sentence[i];
				correct_word_Count++;
			}
		}
		memset(tmp,0,sizeof(wchar_t)*500);
		wcscpy(tmp,Example_sentence);
		typing_duration_Time = (typing_finish_Time-typing_start_Time)+0.5;//CLOCKS_PER_SEC;
		User_input_typist = BreakHan(temp,tmp,sizeof Example_sentence);	//»ç¿ëÀÚ°¡ Á¤È®ÇÏ°Ô ÀÔ·ÂÇÑ Å¸ÀÚ °³¼ö
		memset(tmp,0,sizeof(wchar_t)*500);
		wcscpy(tmp,Example_sentence);
		memset(temp,0,sizeof(wchar_t)*50);
		wcscpy(temp,Example_sentence);
		sentence_word_Count = BreakHan(temp,tmp,sizeof Example_sentence);	//»ç¿ëÀÚ°¡ ÀÔ·ÂÇؾßÇÏ´Â ¿¹½Ã¹®ÀÇ Å¸ÀÚ °³¼ö
		typing_Accuracy = (float)(User_input_typist)/(sentence_word_Count-1)*100;	//Á¤È®µµ °è»ê
		Typist = (User_input_typist*60)/(typing_duration_Time);		//ŸÀÚ¼ö °è»ê
	}

	return 0;
}
コード例 #5
0
ファイル: Source.c プロジェクト: jhKang1313/typing_practice
int Long_sentence_practice(wchar_t*** Long_sentence,int Long_Num,int sentence_Count[],FILE* Info_practice)
{
	wchar_t Example_sentence[50];	//ÇÑÁÙ¾¿ ý
	wchar_t typing_One_word[7][50] = {L"",L"",L"",L"",L"",L"",L""}; //±æ±ÛÀº ÃÖ´ë 7¹®ÀåÀ¸·Î ±¸¼º. ÇÑ ¹®Àå´ç 50°³ÀÇ ¹®ÀÚ ÀúÀå
	wchar_t temp[500] = L"";
	wchar_t tmp[1000];
	double typing_start_Time,typing_finish_Time;
	double typing_duration_Time;
	int start_Typing=1,present = 0,correct_word_Count =0;	//start_typingÀÌ 0À̸é ÀԷ½ÃÀÛ
	int len_Example_sentence ;
	int X_Cursor = 3;		//X Ä¿¼­À§Ä¡
	int Y_Cursor = 5;		//Y Ä¿¼­À§Ä¡
	int i,j = 0;
	int Highest_Typist = 0;		//ÃÖ´ë ŸÀÚ¼ö
	int User_input_typist;		//»ç¿ëÀÚ°¡ ÀÔ·ÂÇÑ ±ÛÀÚ°³¼ö
	long long Typist = 0;		//ŸÀÚ¼ö
	int typing_Accuracy = 0;	//Á¤È®µµ
	int sentence_word_Count;	//±ä±Û ¹®Àå¿¡¼­ÀÇ ±ÛÀÚ°³¼ö
	int Check_accuracy[100] = {-1,};	//-1ÀÌ¸é ¹«ÀÔ·Â »óÅÂ, -2ÀÌ¸é ¸Â´Â ÀÔ·Â, ´Ù¸¥°ªÀ¸¸Â
	int Random;
	int k;
	
	setlocale(LC_ALL, "Korean");
	k = Long_prac_Main(Long_sentence,Long_Num);	//¸Þ´º¿¡¼­ ¸î¹ø° ±ä±ÛÀÎÁö ¼±ÅÃ
	if(k == -1)
		return 0;
	else if(k == -2)
		return -1;
	else
	{
		UI_Long_prac(Long_sentence[k],sentence_Count[k]);	//»ç¿ëÀÚ°¡ ¼±ÅÃÇÑ ±ä±Û Ãâ·Â.
		while(j != sentence_Count[k])		//±ä±ÛÀÌ ³¡³¯‹š±îÁö
		{
			start_Typing = 1;			//°ªµé ÃʱâÈ­
			X_Cursor = 0;
			present = 0;
			memset(Check_accuracy,-1,4*100);
			memset(Example_sentence,0,sizeof(wchar_t)*50);
			
			wcscpy(Example_sentence,Long_sentence[k][j]);		//±ä±ÛÀÇ ÇÑ ¹®ÀåÀ» Àд´Ù.
			len_Example_sentence = wcslen(Example_sentence);	//À§¿¡¼­ ÀÐÀº ¹®ÀåÀÇ ±æÀÌ
			while(1)
			{

				gotoxy(3,4+(j*2));
				for(i = 0 ; i < len_Example_sentence ; i++)		//»ç¿ëÀÚ ÀԷ°ú ¿¹½Ã¹®°úÀÇ ÀÏÄ¡ ½Ç½Ã°£ È®ÀÎ
				{
					if(Check_accuracy[i] == i)		//Ʋ¸±°æ¿ì
					{
						RED;
					}
					else if(Check_accuracy[i] == -2)	//¸Â´Â°æ¿ì
					{
						COROL;
					}
					else			//¹«ÀԷ»óÅÂ
					{
						WHITE;
					}
					printf("%C",Example_sentence[i]);
				}
				if(present>=len_Example_sentence-1)	//¹®ÀÚ ±æÀ̺¸´Ù ¸¹ÀÌ ÀԷ¹ÞÀ¸¸é Á¾·á
				{
					break;
				}	
				gotoxy(3+X_Cursor,Y_Cursor+(j*2));
				typing_One_word[j][present] = _getwche();	//¹®ÀÚ Çϳª¸¦ ÀԷ¹ÞÀ½
				if(typing_One_word[j][present] == 27)	// ESCÅ°¸¦ ´©¸£¸é ¿¬½ÀÁ¾·á
				{
					break;
				}
				if(typing_One_word[j][present] == 8 && present == 0)	//Ä¿¼­°¡ óÀ½ÀÌ°í, ¹é½ºÆäÀ̽º¸¦ ´©¸£¸é 
					gotoxy(X_Cursor+3,Y_Cursor+(j*2));		//µ¿ÀÛ¾ø´Â°Íó·³ º¸ÀÌ°Ô.
				else if(typing_One_word[j][present] == 8)	//¹é½ºÆäÀ̽º¸¦ ´©¸£¸é
				{
					if(present>=1)
					{
						if(Example_sentence[present-1] < 256)	//Àü ±ÛÀÚ°¡ 1byteÀ̸é
						{
							present--;
							X_Cursor-=1;						//Ä¿¼­ Çϳª¸¸ µÚ·Î À̵¿
							gotoxy(X_Cursor+3,Y_Cursor+(j*2));
							printf(" ");		//Áö¿öÁø°Íó·³ º¸ÀÌ°Ô µ¤¾î¾¸
						}
						else				//Àü ±ÛÀÚ°¡ 2byte¸é
						{	
							present--;		
							X_Cursor-=2;		//Ä¿¼­ µÎ°³ À̵¿
							gotoxy(X_Cursor+3,Y_Cursor+(j*2));
							printf("  ");
						}
					}
					Check_accuracy[present] = -1;	//Áö¿öÁø ¿¹½Ã±Û ´Ù½Ã ÇϾá»öÀ¸·Î Ãâ·ÂµÇ°Ô °ª º¯°æ
				}
				else if(typing_One_word[j][present] != Example_sentence[present])  //¿¹½Ã¹®À̶û ´Þ¸¦°æ¿ì
				{
					if(present== 0 && start_Typing == 1 &&j == 0)		//ÃÖÃÊÀԷ½ÿ¡
					{
						start_Typing = 0 ;				//ÃÖÃÊÀԷº¯¼ö 0À¸·Î º¯°æ
						typing_start_Time = (double)(clock())/CLOCKS_PER_SEC;	//ÀÔ·Â ½Ã°£ ½ÃÀÛ
					}
					if(typing_One_word[j][present] <256 && Example_sentence[present] <256)	//¹®ÀÚ Å©±â¿¡ µû¸¥ Ä¿¼­ À̵¿
					{
						X_Cursor+=1;
						Check_accuracy[present] = present;
					}
					else if(typing_One_word[j][present] > 256 && Example_sentence[present] <256)
					{
						if(Example_sentence[present+1] < 256)
						{
							Check_accuracy[present] = present;
							Check_accuracy[present+1] = present+1;
							X_Cursor+= 2;
							present++;
						}
						else
						{
							X_Cursor+= 3;
							Check_accuracy[present] = present;
							Check_accuracy[present+1] = present+1;
							present++;
						}
					}
					else if(typing_One_word[j][present] < 256 && Example_sentence[present] > 256)
					{
						X_Cursor+= 2;
						Check_accuracy[present] = present;
					}
					else if(typing_One_word[j][present] >256 && Example_sentence[present] > 256)
					{
						X_Cursor+= 2;
						Check_accuracy[present] = present;
					}
					present++;
				}
				else  //¿¹½Ã¹®À̶û °°°Ô ÀÔ·Â
				{
					if(present== 0 && start_Typing == 1 &&j == 0)
					{
						start_Typing = 0 ;
						typing_start_Time = (double)(clock())/CLOCKS_PER_SEC;
					}
					if(typing_One_word[j][present] < 256)
					{
						Check_accuracy[present] = -2;
						X_Cursor+= 1;
					}
					else
					{
						Check_accuracy[present] = -2;
						X_Cursor+=2;
					}
					present++;
				}
			}
			if(typing_One_word[j][present] == 27)
			{
				break;
			}
			j++;
		}
		if(typing_One_word[j][present] == 27)		//ÀԷµµÁß ESCÅ° ÀÔ·ÂÇϸé Á¾·á
			return 0;
		typing_finish_Time = (double)(clock())/CLOCKS_PER_SEC;	//¿¬½ÀÁ¾·á½Ã°£
		correct_word_Count = 0;
		for(j = 0 ; j < sentence_Count[k] ; j++)
		{
			memset(Example_sentence,0,sizeof(wchar_t)*50);
			wcscpy(Example_sentence,Long_sentence[k][j]);
			len_Example_sentence = wcslen(Example_sentence);
			for(i = 0 ; i <= len_Example_sentence ; i++)
			{
				if((typing_One_word[j][i] == Example_sentence[i]) && (typing_One_word[j][i] != 0))
				{
					temp[correct_word_Count] = Example_sentence[i];
					correct_word_Count++;
				}
			}
		}
		memset(tmp,0,sizeof(wchar_t)*1000);
		wcscpy(tmp,Example_sentence);
		typing_duration_Time = (typing_finish_Time-typing_start_Time)+0.5;//CLOCKS_PER_SEC;
		User_input_typist = BreakHan(temp,tmp,sizeof temp);	//»ç¿ëÀÚ°¡ ÀÔ·ÂÇÑ Å¸¼ö

		memset(tmp,0,sizeof(wchar_t)*1000);
		wcscpy(tmp,Example_sentence);
		memset(temp,0,sizeof(wchar_t)*500);
		//wcscpy(temp,Example_sentence);
		for(i = 0 ; i < sentence_Count[k] ; i++)
			wcscat(temp,Long_sentence[k][i]);
		sentence_word_Count = BreakHan(temp,tmp,sizeof temp);	//±ä±Û¿¡ ÀÔ·ÂÇØ¾ß Çϴ Ÿ¼ö

		typing_Accuracy = (float)(User_input_typist)/(sentence_word_Count-sentence_Count[k])*100;	//Á¤È®µµ°è»ê
		Typist = (User_input_typist*60)/(typing_duration_Time);		//ŸÀÚ¼ö °è»ê
		/*for( i = 0 ; i < Long_Num ; i++)
		{
			for(j = 0 ; j < sentence_Count[i] ; j++)
				free(Long_sentence[i][j]);
		}
		free(Long_sentence);*/

		Result_Long_prac(typing_Accuracy,Typist);		//°á°úÈ­¸é Ãâ·Â
		fprintf(Info_practice,"%d %d\n",typing_Accuracy,Typist);	//ÅؽºÆ®ÆÄÀÏ¿¡ ¾²±â
	}
}