随笔分类 -  C语言

摘要:功能:把int转为字符数组 eg: int a=100; char ch[3]; itoa(a,ch,10);//十进制 >ch[0]==1;... 阅读全文
posted @ 2016-09-20 22:58 朱小勇 阅读(650) 评论(0) 推荐(0)
摘要:#include <stdio.h>typedef struct student{float score1;float score2;float score3;float avr;}STUDENT;void save(STUDENT * student)//以二进制形式保存{ FILE *fp=NU 阅读全文
posted @ 2016-09-12 11:39 朱小勇 阅读(644) 评论(0) 推荐(0)
摘要:1、int fseek(FILE *fp,long offset,int fromwhere);改变位置指针函数 offset:以fromwhere为当前位置向前或向后移动的字节数,值为正:向后移动,值为负:向前移动。 fromwhere:(1)、SEEK_SET(0):文件开始位置 (2)、SEE 阅读全文
posted @ 2016-09-11 14:52 朱小勇 阅读(733) 评论(0) 推荐(0)
摘要:含义:给已有的类型重新定义了一个方便使用的别名,并没有产生新的数据类型。 eg: 1、 typedef struct Node{ int a; char *b; }PNode; PNode a, b; 2、 typedef double DataType; DataType a; 阅读全文
posted @ 2016-09-11 10:55 朱小勇 阅读(147) 评论(0) 推荐(0)
摘要:int feof(FILE *fp); 返回值: 0:文件未读取结束 1:文件已读取结束 阅读全文
posted @ 2016-09-10 22:55 朱小勇 阅读(2561) 评论(0) 推荐(0)
摘要:一、打开文件 FILE *fp=NULL;//初始化文件指针变量 fp=fopen("test.text","r");//test.text是文件名,r是模式 if(fp==NULL) {dosomething} getchar();//暂时 模式说明: r:只读方式,不能改变硬盘文件状态。如果文件 阅读全文
posted @ 2016-09-10 22:53 朱小勇 阅读(526) 评论(0) 推荐(0)
摘要:1、代码 #include <iostream> #include <string> using namespace std; int main(int argc, char* argv[]) { int a=123; //&a表示a在内存中的地址,也就是123在内存中的地址 cout<<"a: " 阅读全文
posted @ 2016-07-18 14:19 朱小勇 阅读(361) 评论(0) 推荐(0)