小c笔记

c语言常用语句:
1: while(getchar()!='\n'); //清除换行符(fgets必需)
2: int len =strlen(s);
char ch=(char)malloc((len+1)*sizeof(char)); //开辟空间存储一段字符串(string.h)
3:fgets():char *fgets(char *str, int n, FILE *stream(stdin);//常用于存储字符串
4: char word[];
word[strcspn(word, "\n")] = 0; // 移除字符串末尾的换行
5: 判断当前字符是不是数字 可导入<ctype.h>使用isdigit()
如:if (!isdigit(str[i])) {
// str[i]不是数字时执行的代码
}
6:vector去除区间元素:vec.erase(vec.begin()+i,vec.begin()+j+1);//去除区间元素[i,j)

posted @ 2024-12-11 22:54  Qacter  阅读(20)  评论(0)    收藏  举报