
C语言程序
文章平均质量分 50
real肇事者
这个作者很懒,什么都没留下…
展开
-
指针复制字符串
#include<stdio.h> char* str_copy(char *d, const char *s) { char *t = d; while (*d++ = *s++) /*另一种解法*/ ; /*while(d[i] = s[i])*/ return t; /* i++; */ } int main(void) { char s...原创 2018-03-15 09:53:11 · 1399 阅读 · 0 评论 -
错误的方法指针复制字符串
#include<stdio.h> char* str_copy(char *d, const char *s) { char *t = d; while (*d++ = *s++) /*另一种解法*/ ; /*while(d[i] = s[i])*/ return t; /* i++; */ } int main(void) { cha...原创 2018-03-15 09:54:42 · 169 阅读 · 0 评论 -
不加下标运算符查找字符串中的字符出现数
#include<stdio.h> int str_chnum(const char *str, char c) { int n = 0; while(*str){ if (c == *str++) /*这一句代码是关键*/ n++; } return n; } int main(void) { char str[100]; char c; printf(...原创 2018-03-15 11:13:39 · 231 阅读 · 0 评论 -
结构体和指针的用法例子
#include<stdio.h> #define NAME_LEN 64 struct student{ char name[NAME_LEN]; int height; float weight; long schols; }; void hiroko(struct student *std) { if ((*std).height < 180) (*st...原创 2018-03-15 18:04:18 · 490 阅读 · 0 评论 -
返回结构体的函数示例
#include<stdio.h> struct xyz{ int x; long y; double z; }; struct xyz xyz_of(int x, long y, double z) { struct xyz temp; temp.x = x; temp.y = y; temp.z = z; return temp; } int main(void...原创 2018-03-15 21:59:17 · 14101 阅读 · 0 评论 -
typedef使用示例
#include<stdio.h> #define NAME_LEN 64 typedef struct student{ char name[NAME_LEN]; int height; float weight; long schols; }Student; void hiroko(Student *std) { if (std ->height <180)...原创 2018-03-15 22:00:02 · 312 阅读 · 0 评论