當前位置: 首頁>>代碼示例>>C++>>正文


C++ scanf_s函數代碼示例

本文整理匯總了C++中scanf_s函數的典型用法代碼示例。如果您正苦於以下問題:C++ scanf_s函數的具體用法?C++ scanf_s怎麽用?C++ scanf_s使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了scanf_s函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: main

int main(void)
{
	float salary;
	printf("\aEnter your desired monthly salary:");
	printf("$_______\b\b\b\b\b\b\b");
	scanf_s("%f", &salary);
	printf("\n\t$%.2f a month is $%.2f a year.", salary, salary * 12);
	printf("\rGee!\n");

	getchar();
	getchar();


	return 0;
}
開發者ID:gaigemingziyouzhemenanma,項目名稱:c-primer-plus,代碼行數:15,代碼來源:例3.7.cpp

示例2: main

int main()
{
	int len = 28;
	//scanf_s("%d", &len);
	int p[28] = { 32, 103, 24, 88, 95, 70, 97, 15, 102, 6, 79, 46, 51, 37, 93, 108, 9, 58, 53, 58, 79, 36, 58, 91, 78, 58, 61, 81 };
	RadixSort Radix;
	Radix.radixSort(p, len);
	//insert_sort(p, len);
	for (int i = 0; i < len; i++)
	{
		printf("%d,", *(p + i));
	}
	scanf_s("%d", &len);
	return 0;
}
開發者ID:guochens,項目名稱:Algorithm,代碼行數:15,代碼來源:RadixSort.cpp

示例3: te

void te(){
	printf("どこに置く?:");
	do{
		scanf_s("%d", &okimasu);
	} while (okimasu / 10000 != 0||okimasu/100>tate||okimasu%100>yoko);
	if (masu[okimasu / 100][okimasu % 100][0] == bomb){
		endflag = 1;
	}
	else{
		masu[okimasu / 100][okimasu % 100][1] = masu[okimasu / 100][okimasu % 100][0];
		if (masu[okimasu / 100][okimasu % 100][1] == kara){
			kuri_han(okimasu);
		}
	}
}
開發者ID:Goryudyuma,項目名稱:Minesweeper,代碼行數:15,代碼來源:Source.c

示例4: main

int main(void)
{
	char name[40];
	printf("What's your name.\n");
	scanf_s("%s", name);
	printf("Hello,%s.%s\n", name, PRAISE);
	printf("Your name of %d letters occupies %d memory cells.\n",
		strlen(name), sizeof name);
	printf("The phrase of praise has %d letters",
		strlen(PRAISE));
	printf("and occupies %d memory cells.\n", sizeof PRAISE);
	getchar();
	getchar();
	return 0;
}
開發者ID:Ricky-Hao,項目名稱:C-Primer-Plus-Demo,代碼行數:15,代碼來源:prise2.c

示例5: main

int main()
{
	double result = 0.0;
	double base = 0.0;
	int exponent = 0;
	printf("Please input base and exponent: ");
	scanf_s("%lf,%d", &base, &exponent);
	result = Power(base,exponent);
	if (g_InvalidInput == 1)
		printf("The input is invailable!\n");
	else 
		printf("%lf ^ %d = %lf\n",base,exponent,result);

	return 0;
}
開發者ID:KoenChiu,項目名稱:My-LeetCode-Solution,代碼行數:15,代碼來源:main.c

示例6: DeleteVideo

void DeleteVideo(LINKEDLIST* list){
	int temp = 0;
	printf("»èÁ¦ÇÒ ºñµð¿À ¹øÈ£ : ");
	scanf_s("%d", &temp);
	fflush(stdin);
	NODE * pFindFlag = SSearchNumber(list, temp);
	if (pFindFlag)
	{
		list->DeleteAt(list, pFindFlag);
	}
	else
	{
		printf("ÀÏÄ¡ÇÏ´Â ºñµð¿À°¡ ¾ø½À´Ï´Ù.\n");
	}
}
開發者ID:jewelrykim,項目名稱:bitcom_singleprogect_VideoManagement_network,代碼行數:15,代碼來源:VideoMangement.cpp

示例7: removeContact

void removeContact(struct contact *tailContact)
{
	struct contact *currentContact;
	currentContact = (struct contact *)malloc(sizeof(struct contact));
	clearContact(currentContact);

	setCursorPosition(40,4); printColouredText("please enter record id: ", 2);
	fflush(stdin);
	scanf_s("%i", &currentContact->idNum);
	

	findDeleteContact( tailContact, currentContact);

	free(currentContact);
}
開發者ID:VMarisevs,項目名稱:ContactManagementSystem,代碼行數:15,代碼來源:menuedit.c

示例8: main

int main()
{
	int len=7;
	//scanf_s("%d", &len);
	int p[8] = { 6, 12, 4, 63, 2, 35, 11 };
	InsertionSort insert;
	insert.insertionSort(p, len);
	//insert_sort(p, len);
	for (int i = 0; i < len; i++)
	{
		printf("%d,", *(p + i));
	}
	scanf_s("%d", &len);
    return 0;
}
開發者ID:guochens,項目名稱:Algorithm,代碼行數:15,代碼來源:Insertion+Sorting.cpp

示例9: readInput

int readInput(INTERVAL *arr1) // Read input from user
{

	int n = 0;
	char ch;

	while (1)
	{
		scanf_s("%d-%d", &arr1[n].min, &arr1[n].max);
		ch = getchar();
		n++;
		if (ch != ',')  break;
	}
	return n;
}
開發者ID:sergiosarmentosilva,項目名稱:programs,代碼行數:15,代碼來源:Programming+Test.c

示例10: main

void main()
{
	int i, choice = 1;
	startNode = NULL;

	while (choice != 0)
	{
		puts("Please select an option:\n");
		puts("---------------------------------------");
		puts("01\tInsert a Node");
		puts("02\tDelete a Node");
		puts("03\tDisplay all Nodes");
		puts("04\tSearch for a Node");
		puts("\n00\tExit");
		puts("---------------------------------------\n");

		fflush(stdin);
		scanf_s("%d", &choice);

		switch (choice)
		{
		case 1:
			insertNode();
			break;

		case 2:
			deleteNode();
			break;

		case 3:
			displayAll();
			break;

		case 4:
			findNode();
			break;

		case 0:
			break;

		default:
			puts("Invalid selection!\n");
			break;
		}
	}
	free(startNode);
	free(currentNode);
}
開發者ID:worhello,項目名稱:CollegeCode,代碼行數:48,代碼來源:labWeek20.c

示例11: inputItem

void inputItem(ItemStruct* ior_item)
{
    int numberOfArgumentsRecived;
    int okFlag;

    do
    {
        //TODO (Extra): Blanka alla ch_arr innan vi skriver till dem!!
        printf_s("Name of item %d: ", (*ior_item).isId);
        okFlag = readLine(ior_item->isName, sizeof(ior_item->isName));

        if (ior_item->isName[0] == '\0')
        {
            printf_s("Name cannot be empty!\n");
            okFlag = FALSE;
        }
        else if (okFlag == FALSE)
        {
            // Inmatningen är för lång.
            printf_s("WARNING! The entered Name has been truncated!\n");
            okFlag = TRUE;
        }
        // scanf_s("%s", &ior_item->isName[0], sizeof(ior_item->isName)); // Bryter vid mellanslag
        // flushRestOfLine();
    } while (!okFlag);

    do
    {
        printf_s("Number of this item: ");
        numberOfArgumentsRecived = scanf_s("%f", &ior_item->isAmount); // Space after %f replaces flushRestOfLine
        flushRestOfLine();

        if (numberOfArgumentsRecived == 1)
        {
            break;
        }
        else
        {
            printf_s("*** Please enter a number! ***\n");
        }
    } while (TRUE);

    printf_s("Enter the Unit: ");
    okFlag = readLine(ior_item->isUnit, sizeof(ior_item->isUnit));

    // scanf_s("%s", &ior_item->isUnit[0], C_UNIT_NAME_LENGTH);
    // flushRestOfLine();
} // inputItem
開發者ID:kajvi,項目名稱:Programmering_DVA117,代碼行數:48,代碼來源:Labb_62-old.c

示例12: main

int main()
{
	int a[4];
	int i;
	printf("please enter 4 numbers:\n");
	for (i = 0; i < 4; i++)
	{
		scanf_s("%d", &a[i]);
	}
	for (i = 0; i < 4; i++)
	{
		printf("%d  ", *(a + i));
	}
	return 0;

}
開發者ID:huruji,項目名稱:C,代碼行數:16,代碼來源:使用數組名輸出數組.c

示例13: judge3

void judge3() {
	int num;
	printf("請輸入年份:\n");
	scanf_s("%d", &num);
	if (0 == num % 4 && 0 != num%100) {
		printf("%d是閏年\n", num);
	}
	else if (0 == num % 400){
		printf("%d是閏年\n", num);
	}
	else
	{
		printf("%d不是閏年\n", num);
	}
	finish();
}
開發者ID:wuchiuwong,項目名稱:CCpp2016,代碼行數:16,代碼來源:Level0_C1.cpp

示例14: main

int main( void )
{
	std::vector<int> priceTable = {
		1, 5, 8, 9, 10, 17, 17, 20, 24, 30
	};

	int len;
	printf_s( "input rod length : " );
	scanf_s( "%d", &len );

	printf_s( "MaxPrice : %d\n", GetMaxPrice( len, priceTable ) );

	getchar();
	getchar();
	return 0;
}
開發者ID:SlowT,項目名稱:2014_Algorithm_HW,代碼行數:16,代碼來源:hw1-7.cpp

示例15: GetCLDev

	void GetCLDev()
	{
		cl_int ret = 0;
		int index = 0;
		std::vector<cl_device_id> devices;
		GetDeviceIds(devices);
		for (unsigned int i = 0; i < devices.size(); ++i)
		{
			PrintDeviceInfo(i + 1, devices[i]);
		}


		printf("Enter device no:");
		scanf_s("%d", &index);
		m_currentDev = devices[index - 1];
	}
開發者ID:AndersUa,項目名稱:NBody,代碼行數:16,代碼來源:main.cpp


注:本文中的scanf_s函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。