![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C语言学习
danyang_Q
知乎:塔矢小Q
https://www.zhihu.com/people/13132578726
展开
-
通过命令行输入来进行运算
主要是为了理解main()中的指针参量 /* 编写一个通过命令行输入进行运算的程序 */ #include<stdio.h> #include<string.h> #include<stdlib.h> int main(int argc,char ** args) /*int main() { printf("hh");}*/ { int a = atoi(args[1]); int b = atoi(args[3]); char *s = args[2原创 2020-07-27 16:22:48 · 257 阅读 · 0 评论 -
函数定义练习:将数字字符串转化为整型,实现atoi()函数功能
将数字字符串转化为整型,实现atoi()函数功能 例如:输入:“123” 输出:123 (1100+210+3*1) 分析: 需要 字符串长度len 位数乘法 10^(len-1) 字符转数字 例如:‘5’-‘0’=5 //字符串长度 int my_len(const char *s){ int len=0; while(s[len]){ len++; } return len; } //位数乘法 int e_pow(int c){ if(c==0){ return 1;} if(c原创 2020-07-24 15:23:11 · 214 阅读 · 0 评论 -
strtok,strcat ,strcpy ,sscanf , sprintf 的使用
C语言学习函数部分 函数部分 例题:将字符串“12+5=;45-2=;34*2=;56/3=”的结果计算出来,并且填写在等号后面,并将形成的带结果的新字符串重新打印出来。 #include<stdio.h> #include<string.h> int main(){ char a[100]="12+5=;45-2=;34*2=;56/3="; char *s; char b[100]={0}; s=strtok(a,";"); while(s){ char c ; int i,j原创 2020-07-24 09:06:05 · 218 阅读 · 0 评论