参考:http://www.cnblogs.com/qyaizs/articles/2039101.html

C语言:

typedef struct Student{

int score;

}Stu;       //Stu是结构类型,是Student的别名,Stu==struct Student

Stu stu1;   //stu1是一个Stu结构类型的变量

或者

struct Student{

int score;

};    

struct Student  stu1; //stu1是一个Student结构类型的变量,只能这样定义

还或者

typedef struct
{ int score; }Stu; //Stu是结构类型 Stu stu1; //这里只能这样定义一个新的变量

  

C++:

struct Student
{ int score; };   Student stu1;//比C语言少一个struct

并且,如果有typedef:

struct Student1
{ int score; }stu1; //stu1是一个变量 typedef struct Student2
{ int score; }stu2; //stu2是一个结构类型=struct Student2,等同于c语言

总结:

不用记住全部,只要记最习惯的写法,用c++:

struct Student
{ int score; }stu1; //stu1是一个变量 Student stu2,stu3;

struct和typedef struct用法的更多相关文章

  1. struct和typedef struct的用法

    我首先想到的去MSDN上看看sturct到底是什么东西,虽然平时都在用,但是每次用的时候都搞不清楚到底这两个东西有什么区别,既然微软有MSDN,我们为什么不好好利用呢,下面是摘自MSDN中的一段话: ...

  2. [转载]彻底弄清struct和typedef struct

    struct和typedef struct 分三块来讲述: 1 首先://注意在C和C++里不同 在C中定义一个结构体类型要用typedef: typedef struct Student { int ...

  3. struct和typedef struct彻底明白了

    struct和typedef struct 分三块来讲述: 1 首先://注意在C和C++里不同 在C中定义一个结构体类型要用typedef: typedef struct Student { int ...

  4. struct和typedef struct

    转自:http://www.cnblogs.com/qyaizs/articles/2039101.html struct和typedef struct 分三块来讲述: 1 首先://注意在C和C++ ...

  5. 细说 struct和typedef struct

    细说 struct和typedef struct 参考原文:http://www.cnblogs.com/qyaizs/articles/2039101.html,有些小改动~ 1 首先://注意在C ...

  6. C++/C中的struct和typedef struct用法和区别

    struct和typedef struct 分三块来讲述: 1 首先://注意在C和C++里不同 在C中定义一个结构体类型要用typedef: typedef struct Student { int ...

  7. struct和typedef struct在c++中的用法

    #include<iostream> using namespace std; struct test{ int a; }test; //定义了结构体类型test,声明变量时候直接test ...

  8. struct和typedef struct在c语言中的用法

    在c语言中,定义一个结构体要用typedef ,例如下面的示例代码,Stack sq:中的Stack就是struct Stack的别名. 如果没有用到typedef,例如定义 struct test1 ...

  9. struct 和typedef struct的区别

    和int char一样struct也是一种数据类型,也可以声明变量--结构变量. 定义结构体变量的一般格式为: struct 结构名 { 类型 变量名; 类型 变量名; ... }结构变量; 另一种常 ...

随机推荐

  1. poj 2892

    Tunnel Warfare Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 7725   Accepted: 3188 D ...

  2. 4种sql分页

    四种方式实现SQLServer 分页查询 SQLServer 的数据分页: 假设现在有这样的一张表:CREATE TABLE test( id int primary key not null ide ...

  3. HTML 学习笔记(链接)

    HTML链接 超链接可以是一个字,一个词,或者一组词,也可以是一幅图像,您可以点击这些内容来跳转到新的文档或者当前文档中的某个部分. 当您把鼠标指针移动到网页中的某个链接上时,箭头会变为一只小手. 我 ...

  4. JavaScript Boolean 对象

    JavaScript Boolean 对象 Boolean 对象 Boolean 对象用于转换一个不是 Boolean 类型的值转换为 Boolean 类型值 (true 或者false). Bool ...

  5. docker中如何制作自己的基础镜像

    一.本地镜像 举个例子:现在把自己的开发环境打包,取名为centos6-base.tar,然后在docker中,以centos6-base.tar作为基准镜像. 1.创建自己的镜像,放置于/root目 ...

  6. scala + intellij idea 环境搭建及编译、打包

    大数据生态圈中风头正旺的Spark项目完全是采用Scala语言开发的,不懂Scala的话,基本上就没法玩下去了.Scala与Java编译后的class均可以运行于JVM之上,就好象.NET中F#与C# ...

  7. ICSharpCode.SharpZipLib

    ICSharpCode.SharpZipLib 压缩.解压文件 附源码   http://www.icsharpcode.net/opensource/sharpziplib/ 有SharpZipli ...

  8. C# 值类型和引用类型

    一.基本概念 C#只有两种数据类型:值类型和引用类型 值类型在线程栈分配空间,引用类型在托管堆分配空间 值类型转为引用类型称成为装箱,引用类型转为值类型称为拆箱 以下是值类型和引用类型对照表 从上图可 ...

  9. 提高Visual Studio开发性能的几款插件

    通过打开Visual Studio,单机TOOLS—Extensions and Updates-Online-Visual Studio Gallery(工具-扩展和更新-联网-Visual Stu ...

  10. Common Issues Which Cause Roles to Recycle

    This section lists some of the common causes of deployment problems, and offers troubleshooting tips ...