- 博客(19)
- 收藏
- 关注
转载 C语言中指针变量的初始化
a.赋值一个已有变量的地址int a;int *p=&a;b.新开辟一块内存空间int *p=(int*)malloc(size(int));c.赋空值int *p=NULL;
2013-05-11 19:18:16 543
原创 C语言 指针数组
#include "stdio.h"#include "stdlib.h"int main(){ char *ps[]={"abin","lee","varyall"}; printf("%s.\n",ps[0]); printf("%s.\n",ps[1]); printf("%s.\n",ps[2]); printf("%s.\n",*(ps)); printf
2013-05-10 00:11:26 443
原创 C语言 字符串指针初始化
#include "stdio.h"#include "stdlib.h"int main(){ char *ps=(char*)malloc(sizeof(char)*3); ps="abc"; free(ps); printf("%s.\n",ps);}
2013-05-10 00:02:54 1943
原创 C语言结构体实例一
#include "stdio.h"#define LEN 20struct info{char first[LEN];char last[LEN];int age; };int main(){struct info boy={"abin" ,"lee" ,20};printf("%s %s %d.\n",boy.first,boy.last,boy.age
2013-05-08 20:29:11 576
原创 C语言指针开辟内存释放内存
#include "stdio.h"#include "string.h"#include "stdlib.h"int main(){char *a=NULL;char *b=NULL;a=(char*)malloc(100);b=(char*)malloc(100);a="abc";b="abc";int result=strcmp(a,b);prin
2013-05-08 00:18:02 904
原创 C++ 多线程实例一
#include #include using namespace std;DWORD WINAPI Fun(LPVOID IpParamter){ while(1){ cout Sleep(1000);}}int main(int argc,char *argv[]){ HANDLE hThread=CreateThread(NULL,0,Fun,NULL
2013-04-23 23:58:40 399
转载 c语言不同源文件间函数的调用
yan335998206| 分类:C/C++| 浏览2236次很多程序中,经常要用到延时函数 ,如下void delay(){int i,j;for(i=0;i<255;i++) for(l=0;j<255;j++);}每次用这函数都要写一遍,我就想把它单独写成一个源文件,以后直接调用。该怎么做啊,谢谢指教。我有更好的答案提问者采纳200
2013-04-06 21:29:20 1154
原创 普通C++类的定义
#include using namespace std;class UnionStd{ public: int GetAge(); void SetAge(int age); void Call(); private: int UnionStd::itAge;};int UnionStd::GetAge(){ return itAge;}voi
2013-04-06 21:28:38 480
原创 C语言switch语句
#include "stdio.h"int main(int argc,char *argv[]){printf("please input a number:\n");int num;scanf("%d",&num);printf("\n");while(1){switch(num){case 1:printf("you input num is:%d
2012-03-26 23:22:05 347
原创 C语言读文件(一)
#include "stdio.h"int main(int argc,char *argv[]){FILE *fp;char ch;fp=fopen("one.txt","rt");if(fp==NULL){printf("can not one.txt\n");getch();exit(1);}printf("now i can read a
2012-03-26 22:17:24 337
原创 C语言写文件操作(一)
#include "stdio.h"int main(int argc,char *argv[]){FILE *fp;char ch;fp=fopen("one.txt","wt+");if(fp==NULL){printf("can not this file");getch();exit(1);}printf("please input a
2012-03-26 22:03:46 238
原创 C语言 写文件操作
#include "stdio.h"int main(int argc,char *argv){FILE *fp;char ch;if((fp=fopen("aaa.txt","wt+"))==NULL){printf("Cannot open file!");getch();exit(1); }printf("input a string:\n")
2012-03-22 23:40:59 292
原创 C语言 指针连接字符串(二)
#include "stdio.h"int main(int argc,char * argv[]){ char *connect(char *s1,char *s2); char s1[80],s2[80]; gets(s1); gets(s2); puts(connect(s1,s2)); return 0;}char *connect(char *s1
2012-03-22 14:24:03 1037
原创 C语言连接字符串
#include "stdio.h"int main(int argc,char * argv[]){char c[40];char a[20]="ab";char b[20]="cd";strcpy(c,strcat(a,b));printf("c=%s\n",c);// printf(strcat(a,b));return 0;}
2012-03-22 13:10:28 417
原创 C语言 指针连接两个字符串(一)
#include "stdio.h"int main(int argc,char *argv[]){char *mystr(char *s1,char *s2);char s1[80],s2[80];gets(s1);gets(s2);puts(mystr(s1,s2));return 0;}char *mystr(char *s1,char *s2
2012-03-22 11:15:48 1658
原创 C语言 strcat连接符
#include "stdio.h"int main(int argc,char *argv[]){char buf[100]="i love";char *tem="you !";strcat(buf,tem);puts(buf); getchar();return 0;}
2012-03-21 23:55:19 339
原创 C语言 头文件(.h)使用方法
//abing.h#include "stdio.h"int plus(int one,int two);char show(char a,char b);//plus.c#include "stdio.h"int plus(int one,int two){int c=0;c=one+two;return c; }//s
2012-03-21 23:37:06 798
原创 C语言生成TXT文件
#include int main(int argc,char *argv[]){FILE *fp;fp=fopen(argv[1],"w");fputs("i love you",fp);fclose(fp);return 0;}Microsoft Windows [版本 6.1.7600]版权所有 (c) 2009 Micro
2012-03-20 00:03:42 2945
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人