随笔分类 -  C/C++/QT

摘要:#include <stdio.h> #include <stdlib.h> struct Student { int age; //4 float score; // 4/ long id; //4 char sex ; //2 vc 6.0 14 }; main() { struct Student st={80,55.6f,100010 ,'F'}; struct Student* pst; pst = &st; printf("age = %d\n",st.age); print... 阅读全文
posted @ 2012-11-08 19:32 sfshine 阅读(206) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2012-11-08 19:09 sfshine 阅读(103) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <stdlib.h> #define pi 3.1415 //定义全局变量 存放在code区 // 作业: 从键盘接受一个数组 数组的大小 随着输入数据的变化 而变化 void printArr(int* arr, int len){ // arr是数组的首地址 len数组的长度 int i=0; for(;i<len;i++){ // 在c99 的语法格式下 for循环的初始化条件 不能写在 for 循环的括号里面 // printf("arr[... 阅读全文
posted @ 2012-11-08 19:01 sfshine 阅读(610) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <stdlib.h> main() { int i =3; double d = 3.141692; float f = 3.1423; char c ='B'; int* ip = &i; double* dp = &d; float* fp = &f; char* cp = &c; printf("int 类型指针变量的... 阅读全文
posted @ 2012-11-08 17:44 sfshine 阅读(256) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <stdlib.h> // 数组是一块连续的内存空间 数组名 就是内存空间的首地址 // 数组名[i] == *(数组名+i); main() { /* char[] arr = new char[20]; char arr[] ; */ // 创建一个长度为5的int类型的数组 int arr[5] ={1,2,3,4,5}; p... 阅读全文
posted @ 2012-11-08 16:50 sfshine 阅读(193) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <stdlib.h> main() { char arr[20] ={'h','e','l','l','o','\0'};//char数组表示字符串很麻烦 // 利用char类型指针 方便的表示一个字符串 char* arr1= "hello world"; printf("%s",arr1); //%s是字符串的占位符 arr1是一个地址 system("pause&q 阅读全文
posted @ 2012-11-08 16:49 sfshine 阅读(394) 评论(0) 推荐(0)
摘要:l指针就是地址,地址就是指针l地址就是内存单元的编号l指针变量是存放地址的变量l指针和指针变量是两个不同的概念l但是要注意: 通常我们叙述时会把指针变量简称为指针,实际它们含义并不一样int a = 1;为a赋值为1int* p p就表示一个指针也就是一个元素的地址p = &a;int** q; 表示一个指针的地址 (二重指针)q = &p; 阅读全文
posted @ 2012-11-07 21:50 sfshine 阅读(136) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <stdlib.h> /*&根据值找地址 *根据地址找值 */ f(int** q){//传入的是指针的地址 int i = 3; printf("子函数 i的地址 %#X\n",&i); // *q 代表的就是p变量 *q = &i; //*q指向是p的值 也就是把p地址(比如&p=220005)所指向的值(也即是p)赋成了i的地址/ } /** 使用指针的时候 不可以访问已经被系统回收掉的数据 子函数执行完... 阅读全文
posted @ 2012-11-07 21:41 sfshine 阅读(338) 评论(0) 推荐(0)
摘要:#include<QtCore/QCoreApplication>#include <QFile>#include <stdio.h>#include <QDir>#include <QTextCodec>#include <QTextStream>void delFile(){ int count=0; QDir myDir("C:/TEMP/"); QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); for( 阅读全文
posted @ 2012-05-14 18:19 sfshine 阅读(717) 评论(0) 推荐(0)