惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy International News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Troy Hunt's Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Attack and Defense Labs
Attack and Defense Labs
S
Secure Thoughts
V2EX - 技术
V2EX - 技术
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
O
OpenAI News
Cloudbric
Cloudbric
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Help Net Security
Help Net Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tenable Blog
S
Security @ Cisco Blogs
N
News and Events Feed by Topic
The Hacker News
The Hacker News
C
CXSECURITY Database RSS Feed - CXSecurity.com
宝玉的分享
宝玉的分享
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
V
Visual Studio Blog
P
Proofpoint News Feed
Webroot Blog
Webroot Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 三生石上(FineUI控件)
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
L
LangChain Blog
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东

博客园 - 萧佰刚

Mtk Ft6306 touch 驱动 . 深圳市鑫侑触控技术有限公司 电容式触摸屏|电容式触摸屏厂|手机触摸屏厂|偏光片贴合 Qt Creator 常用快捷键 结构体指针的指针使用(转) System V共享内存资料 "互斥锁用于上锁,条件变量则用于等待" Linux下UDP编程 Linux Socket编程学习 linux管道学习资料 linux进程间通信——消息队列 C实现单链表(转) c语言 位操作 C语言枚举类型使用简介 字符数组 字符指针 sizeof strlen 的区别 Linux进程间共享临界区“信号量”编程 Linux下Socket编程 Linux下常用函数- 信号处理函数(转) linux信号signal常用信号 Linux 守护进程的编程方法(转)
指向结构体指针的例子
萧佰刚 · 2011-05-26 · via 博客园 - 萧佰刚

#include<stdio.h>
#define LEN 20
struct names
{
  
char first[LEN];
  
char last[LEN];
};struct guy
{
  
struct names handle;
  
char favfood[LEN];
  
char job[LEN];
  
float income;
};int main(void)
{
     
struct guy fellow[2]=
     {
        {{"Ewen","Villard"},"grilled salmon","personality coach",58112.00},
        {{"Rodney","Swillbelly"},"tripe""tabbid editor",232400.00}
    };
     
    
struct guy *him;    printf("address #1: %p  #2: %p\n",&fellow[0],&fellow[1]);
    
    him=&fellow[0];    printf("pointer #1: %p #2: %p\n",him,him+1);    printf("him->income is $%.2f  (*him)income is $%.2f\n",him->income,(*him).income);    him++;    printf("him->favfood is %s  him->handle.last is %s\n",him->favfood,him->handle.last);return 0;
}

输出结果

address #1:0x0012fea4 #2:0x0012fef8pointer #1:0x0012fea4 #2:0x0012fef8him->income is $58112.00: (*him).income is $58112.00him->favfood is tripe: him->handle.last is Swillbelly

 

结构(fellow)作为函数的参数传递分类 

1:传递结构成员      例如:function(fellow[0].income)
2:传递结构地址      例如:function(&fellow[0])
3:把结构作为参数传递  例如:function(fellow[0])
4:把一个结构赋值给另外一个结构 例如:fellow[0]=fellow[1]
5:结构不能直接赋值给指针(需&取地址),而数组可以直接赋值给指针   例如:p=&fellow[0] 或 p=数组名