⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pass_struct_pointer_to_function3.cpp

📁 How to use nested struct
💻 CPP
字号:
#include <stdio.h>
#include <conio.h>
#include <mem.h>

	typedef struct /* Defines the structure */
		{
			char name[20];
			int numb;
			float amt;
		}cust;

	void intcal(cust *abc);

	void main()
	{

		cust xyz,a;
		clrscr();

		/* Accepts data into the structure */
		printf("\nEnter Customer name: ");
		gets(xyz.name);

		printf("\nEnter Customer number: ");
		scanf("%d",&xyz.numb);

		printf("\nEnter Principal amount: ");
		scanf("%f", &xyz.amt);

		//a=xyz;
		//memcpy(&a,&xyz,sizeof(cust));

		intcal(&xyz); /* Passes the structure to a function */

		getch();
	}

	void intcal(cust *abc)
	{
	float si, rate = 5.5, yrs = 2.5;

		/* Computes the interest */
		si = (abc->amt * rate*yrs) / 100;

		printf ("\nThe customer name is %s",abc->name);
		printf("\nThe customer number is %d",abc->numb);
		printf("\nThe amount is %f",abc->amt);
		printf("\nThe interest is %f",si);

		return;
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -