上一页 1 ··· 31 32 33 34 35 36 37 38 39 ··· 57 下一页
  2011年10月14日
摘要: 1,在输入字符串时,空格作为字符串之间的分隔符char e[14]; scanf("%s",e); printf("%s\n",e);若输入how are you 时,则只把how的值赋给e变量。 2. 要输出内存地址时,可使用%u,% o,%x.如下: printf("%u,%o,%x",f,f,f);其中f是数组名。 阅读全文
posted @ 2011-10-14 15:56 wtq 阅读(479) 评论(0) 推荐(0) 编辑
摘要: 1,字符数组中的特殊字符‘、'\0'的作用char a[10] = {'i',' ','a','m',' ','c','h','i','n','a'}; char b[]="i am china"; printf("%d\n",strlen(a)); printf("%d\n",strlen(b)); printf("%s\n",a); pr 阅读全文
posted @ 2011-10-14 13:32 wtq 阅读(271) 评论(0) 推荐(0) 编辑
  2011年10月13日
摘要: 1,同时完成赋值以及输出的功能 int a = 12; int b =3; printf("%d\n",a+=a-=a*a); printf("%d",a = b); //同时完成赋值和输出功能。2.逗号表达式的取值是最后一个表达式的值。3在printf函数中,如果想输出%号,应该使用俩个%号,如%%。4,格式说明符:d,ld,f,c,s,e,u,g,o,x5格式化scanf,如制定输入整型的位数。代码如下: long a =900000; int b,c; scanf("%3d%3d",&b,&c); printf( 阅读全文
posted @ 2011-10-13 15:10 wtq 阅读(265) 评论(0) 推荐(0) 编辑
  2011年10月12日
摘要: 1,\ddd表示八进制。应用:\101输出字母A,代码如下:char ch ='\101'; printf("%c",ch);2在c语言的强制类型转换时,得到的是一个所需类型的中间变量,原来变量的类型未发生变化,float f;int i;f=3.4;i = (int)f;printf("i= %d,f = %f",i,f);此句输出的是3和3.4,变量f仍然是3.43,在进行运算符进行结合时,如下代码int ii;ii=3;printf("-ii++=%d\n",-ii++);printf("ii=%d\n 阅读全文
posted @ 2011-10-12 22:03 wtq 阅读(445) 评论(0) 推荐(0) 编辑
摘要: char *strstr(char *p1,char *a){ char *p2,*p; for(;*p1!='\0';) { p2=p1; p=a; for(;*p!='\0';) { if(*p==*p2) { p++; p2++; } else { break; } } if(*p=='\0') { return p1; } p1++; } return 0;} 阅读全文
posted @ 2011-10-12 16:08 wtq 阅读(411) 评论(0) 推荐(0) 编辑
摘要: char *strlower(char *p1){ char *p2; p2 = p1; for(;*p1!='\0';) { if(*p1<=90 && *p1>=65) { *p1 = *p1+32; } p1++; } return p2;} 阅读全文
posted @ 2011-10-12 13:17 wtq 阅读(776) 评论(0) 推荐(0) 编辑
摘要: char *strup(char *p1){ char *p2; p2 = p1; for(;*p1!='\0';) { if(*p1<=122 && *p1>=97) { *p1 = *p1-32; } p1++; } return p2;} 阅读全文
posted @ 2011-10-12 13:15 wtq 阅读(327) 评论(0) 推荐(0) 编辑
摘要: int strlen(char *p1){ int length; length=0; while(*p1++) length++; return length;} 阅读全文
posted @ 2011-10-12 13:02 wtq 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 方法1; void strcopy(char *p1,char *p2){ for(;*p1!='\0';) { *p2++=*p1++; } *p2='\0'; }方法2:void strcopy(char *p1,char *p2){ for(;(*p2++=*p1++)!=0;); }方法3.void strcopy(char *p1,char *p2){ while(*p2++=*p1++); } 阅读全文
posted @ 2011-10-12 12:59 wtq 阅读(402) 评论(0) 推荐(0) 编辑
摘要: 代码如下:int strcmp(char *p1,char *p2){ for(;*p1!='\0';) { if(*p1>*p2 )) { return 1 ; } else if((*p1<*p2)) { return -1; } p1++; p2++; } return 0;} 阅读全文
posted @ 2011-10-12 12:44 wtq 阅读(459) 评论(0) 推荐(0) 编辑
上一页 1 ··· 31 32 33 34 35 36 37 38 39 ··· 57 下一页