- 博客(5)
- 收藏
- 关注
原创 字符串学习
令人遗憾的是,c语言中并没有string这个数据变量,需要用字符数组来代表存储字符串。所以,字符串的直接赋值在c语言中是无效的。字符串的声明,初始化,输出及理解内存布局。什么是字符串?字符串就是字符数组,末尾用截止符\0标记。使用strcpy()函数初始化字符串头文件include<string.h>语法/原型:char* strcpy(char* strDestination, const char* strSource);参数说明:strDestina
2022-05-12 11:37:49
158
原创 键盘键入字符串并计算字母数字空格或者其他字符的数量
int main(){ int a=0,b=0,c=0,d=0;//a存储英文字母个数,b存储空格的个数,c存储数字的个数,d存储其他字符个数 char x; printf("输入一行字符串:\n"); while((x=getchar())!='\n')//对字符串中的每一个字符进行比较判断 { if(x>='a'&&x<='z'||x>='A'&&x<='Z') a++; else if(x==' ') b++;.
2022-05-09 09:27:58
482
原创 单个字符的输入输出
putchar()code:#include <stdio.h>int main (){ char ch; for(ch = 'A' ; ch <= 'Z' ; ch++) { putchar(ch); printf("\n"); } return(0);}screen:
2022-05-08 13:03:47
827
原创 c语言文件数据读取输出
code:#include <stdio.h>#include <stdlib.h>#include <time.h>#include<math.h>//文件读取练习,读取并打印出指定文件int main(){ FILE*fp; fp = fopen("experiment1data.txt","r"); int num; char sname[20]; int score; w...
2022-05-07 16:16:47
6092
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅