
啊我摔倒了..有没有人扶我起来学习....
👱个人主页: 《 C G o d 的个人主页》 \color{Darkorange}{《CGod的个人主页》} 《CGod的个人主页》交个朋友叭~
💒个人社区: 《编程成神技术交流社区》 \color{Darkorange}{《编程成神技术交流社区》} 《编程成神技术交流社区》加入我们,一起高效学习,收割好Offer叭~
🌱刷题链接: 《 L e e t C o d e 》 \color{Darkorange}{《LeetCode》} 《LeetCode》快速成长的渠道哦~
C语言中对字符和字符串的处理很是频繁,但是C语言本身是没有字符串类型的,字符串通常放在常量字符串中或者字符数组中char * strtok ( char * str, const char * sep );
sep参数是个字符串,定义了用作分隔符的字符集合0个或者多个由sep字符串中一个或者多个分隔符分割的标记strtok函数找到str中的下一个标记,并将其用 \0 结尾,返回一个指向这个标记的指针(注:strtok函数会改变被操作的字符串,所以在使用strtok函数切分的字符串一般都是临时拷贝的内容strtok函数的第一个参数不为 NULL ,函数将找到str中第一个标记,strtok函数将保存它在字符串strtok函数的第一个参数为 NULL ,函数将在同一个字符串中被保存的位置开始,查找下一个标NULL 指针#include
#include
int main()
{
char str[] = "- This, a sample string.";
char* pch;
printf("Splitting string \"%s\" into tokens:\n", str);
pch = strtok(str, " ,.-");
while (pch != NULL)
{
printf("%s\n", pch);
pch = strtok(NULL, " ,.-");
}
return 0;
}
输出结果:
#include
#include
#include //必须包含的头文件
int main()
{
FILE* pFile;
pFile = fopen("unexist.ent", "r");
if (pFile == NULL)
printf("Error opening file unexist.ent: %s\n", strerror(errno));
//errno: Last error number
return 0;
}
输出结果:

int tolower ( int c );
int toupper ( int c );
#include
#include
int main()
{
int i = 0;
char str[] = "Test String.\n";
char c;
while (str[i])
{
c = str[i];
if (isupper(c))
c = tolower(c);
putchar(c);
i++;
}
return 0;
}
输出结果:
