C语言
文章平均质量分 72
liu_su
这个作者很懒,什么都没留下…
展开
-
C语言字符串转换大写
要求:比如1gjfg45 转换成:1GIFG45#include int main() { char str[100] = "nishiw34odeyan4343"; char tar[100]; int index = 0; int pos = 0; //转换为大写 while(str[index] != '\0') { str[index] = (st原创 2012-03-10 20:11:14 · 1914 阅读 · 0 评论 -
传值Or传址
所有的参数传递都是值传递#include typedef char *String;typedef String *STRING;void change1(String);void change2(STRING);int main() { char *name = "Hello world!"; puts(name); change1(name);原创 2012-03-12 13:47:33 · 287 阅读 · 0 评论 -
C语言中的指针与数组
char *str = "what's your name?";char src[] = "if you can think of anything, fake it";编译器会把src看作是数组元素的首地址,&src[0]的同义词。注意:在数组形式中src是一个地址常量,不能更改,因为这意味着更改数组的存储的位置(地址)。可以使用src+1来标识数组里的下一个元素。但不能用+原创 2012-03-30 16:07:39 · 312 阅读 · 0 评论 -
C语言字符串char *和char[]——摘自《C primer plus》
Defining Strings Within a ProgramAs you probably noticed when you read Listing 11.1, there are many ways to define a string. The principal ways are using string constants, using char arrays, usi翻译 2012-03-15 11:12:59 · 2866 阅读 · 4 评论 -
sizeof和strlen的区别
char * a = "woyizhiza";char b[10] = "woyizhiza";可以通过一个程序看一下:#include #include int main(){ char *a = "woyizhiza"; char b[10] = "woyizhiza"; printf("%d\t%d\n", sizeof(a), strlen(a))原创 2012-03-15 12:51:25 · 392 阅读 · 0 评论