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

C++ scanf_s函数代码示例

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

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



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


示例16: main

int main(void)
{
   int t_ct; // term count
   double time, x;
   int limit;

   printf("Enter the number of terms you want: ");
   scanf_s("%d", &limit);
   for (time = 0, x = 1, t_ct = 1; t_ct <= limit; t_ct++, x *= 2.0)
   {
      time += 1.0 / x;
      printf("time = %f when terms = %d.\n", time, t_ct);
   }

   return 0;
}
开发者ID:dwinner,项目名称:CppAppdev,代码行数:16,代码来源:zeno.c


示例17: main

int main(void)
{
	float weight;
	float value;
	printf("Are you worth your weight in rhodium?\n");
	printf("Let's check it out!\n");
	printf("Please enter you weight in pounds.\n");
	scanf_s("%f", &weight);
	value = 770 * weight*14.5833;
	printf("Your weight in rhodium is worth $%.2f\n", value);
	printf("You are easily worth that!If rhodium prise drop,\n");
	printf("eat more to maintain you value!");
	getchar();
	getchar();
	return 0;
}
开发者ID:Ricky-Hao,项目名称:C-Primer-Plus-Demo,代码行数:16,代码来源:rhodium.c


示例18: main

int main()
{
	FILE *f;
	freopen_s(&f, "input.txt", "r", stdin);
	
	char ch;
	int i;

	fseek(f, 2, SEEK_SET);
	scanf_s("%c", &ch);
	
	freopen_s(&f, "output.txt", "w", stdout);
	printf("%c %d", ch,ch);

	return 0;
}
开发者ID:sylvester127,项目名称:Algorithm,代码行数:16,代码来源:16.c


示例19: ovning3_A

void ovning3_A()
{
	int tal;

	printf("Ange tal:");
	scanf_s("%d", &tal);

	if (tal % 2 == 0)
	{
		printf("Tal är jämnt \n");
	}
	else
	{
		printf("Tal är udda \n");
	}
}
开发者ID:ozzieem,项目名称:UniCpp,代码行数:16,代码来源:ovningar.c


示例20: main

int main()
{
	char board[BOARD_SIZE][BOARD_SIZE];
	init_board(board);
	board[3][3] = WHITE_K;
	//board[2][4] = BLACK_M;
	//board[4][4] = BLACK_M;
	//board[5][7] = EMPTY;
	print_board(board);
	print_message(WRONG_MINIMAX_DEPTH);
	perror_message("TEST");
	Move* m = get_all_moves(board, WHITE);
	print_moves(m);
	scanf_s("DONE");
	return 0;
}
开发者ID:guysalama,项目名称:ex3_draughts,代码行数:16,代码来源:Draughts.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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