eg0.cpp

来自「C++课程更学习...对于初学者很有好出」· C++ 代码 · 共 55 行

CPP
55
字号
// eg0.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>
#include <string.h>

// 结构体
struct Student
{
	char  m_sName[40];   // 姓名
	int   m_nID;         // 学号
	int   m_nAge;        // 年龄
	int   m_nClassNo;    // 班号 
};

void InitStudent(Student* pStu,
	char* sName, int nID,
	int nAge, int nClassNo)
{
	strcpy(pStu->m_sName, sName);
	pStu->m_nID = nID;
	pStu->m_nAge = nAge;
	pStu->m_nClassNo = nClassNo;
}

void ShowInfo(Student* pStu)
{
	printf("姓名: %s 学号:%d 年龄:%d 班号:%d\n", 
		pStu->m_sName, 
		pStu->m_nID, 
		pStu->m_nAge, 
		pStu->m_nClassNo);
}

void UnitStudent()
{
	// Nothing need to do.
}

int main(int argc, char* argv[])
{
	Student Jack;

	strcpy(Jack.m_sName, "Jack");
	Jack.m_nID = 30;
	Jack.m_nAge = 21;
	Jack.m_nClassNo = 101;

	InitStudent(&Jack, "Jack", 30, 21, 101);
	ShowInfo(&Jack);

	return 0;
}

⌨️ 快捷键说明

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