putchar
- 把参数 char 指定的字符(一个无符号字符)写入到标准输出 stdout 中。
- 返回值:该函数以无符号 char 强制转换为 int 的形式返回写入的字符,如果发生错误则返回 EOF。
int putchar(int char)
#include
int main ()
{
char ch;
for(ch = 'A' ; ch <= 'Z' ; ch++) {
putchar(ch);
}
return(0);
}
putc
- 把参数 char 指定的字符(一个无符号字符)写入到指定的流 stream 中,并把位置标识符往前移动。
int putc(int char, FILE *stream)
#include
int main ()
{
FILE *fp;
int ch;
fp = fopen("file.txt", "w");
for( ch = 33 ; ch <= 100; ch++ )
{
putc(ch, fp);
}
fclose(fp);
return(0);
}
strtok
char *strtok(char *str, const char *delim)
#include
#include
int main () {
char str[80] = "This is - www.runoob.com - website";
const char s[2] = "-";
char *token;
/* 获取第一个子字符串 */
token = strtok(str, s);
/* 继续获取其他的子字符串 */
while( token != NULL ) {
printf( "%s\n", token );
token = strtok(NULL, s);
}
return(0);
}