当前位置: 首页>>代码示例>>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()
{
	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

示例5: 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

示例6: 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

示例7: 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

示例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;未经允许,请勿转载。