C语言第四课

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
struct Book
{
    char name[20];//c语言程序设计
    short prize;//55
};
int main()
{
    
    struct Book b1 = { "c语言程序设计",55 };
    printf("书名:%s\n", b1.name);
    printf("价格:%d元\n",b1.prize);
    b1.prize = 15;
    printf("修改后的价格%d\n", b1.prize);

    return 0;
}
结构体的使用

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
struct Book
{
    char name[20];//c语言程序设计
    short prize;//55
};
int main()
{
    
    struct Book b1 = { "c语言程序设计",55 };
    printf("书名:%s\n", b1.name);
    printf("价格:%d元\n",b1.prize);
    b1.prize = 15;
    printf("修改后的价格%d\n", b1.prize);
     struct Book *pb = &b1;
     printf("%s\n", pb->name);
     printf("%d\n", pb->prize);
    
    return 0;
}
结构体变量.成员

结构体指针->成员

strcpy(b1.name,"c++")字符串拷贝函数,左边是目的地,右边是内容。

学习(c/c++)

学习数据结构(DS)

学习系统&网络(Linux+系统编程+网络基础+网络编程)

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;


//struct Book
//{
//    char name[20];//c语言程序设计
//    short prize;//55
//};

int main()
{
    int age = 100;
    if (age < 18)
        printf("weichengnian\n");
    else if (age >= 18 && age <= 28)
        printf("qingnian\n");
    else if (age > 28 && age < 50)
        printf("zhuangnian");
    else
        printf("laobusi");

    
    return 0;
}
多次选择其中使用else if

else与最近的if进行匹配

switch 跟default匹配

假如所有的case没有,则走default!

 int ch = getchar();
     putchar(ch);
一个是输入字符,一个是输出字符。

 while ((ch = getchar()) != EOF)

Ctrl +z才会停止。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值