c语言putchar函数
C语言中的putchar()函数 (putchar() function in C)
The putchar() function is defined in the <stdio.h> header file.
putchar()函数在<stdio.h>头文件中定义。
Prototype:
原型:
int putchar(const char *string);
Parameters: const char *string
参数: const char * string
Return type: int
返回类型: int
Use of function:
使用功能:
In the file handling, through the putchar() function, we take the character to the stream stdout and store them into the specified string array. The prototype of the function putchar() is int putchar(const char *string);
在文件处理中,通过putchar()函数 ,我们将字符带到流stdout并将其存储到指定的字符串数组中。 函数putchar()的原型是int putchar(const char * string);
The character which is read is an unsigned char which is converted to an integer value. In the case of file handling, it returns EOF when end-of-file is encountered. If there is an error then it also returns EOF.
读取的字符是无符号字符 ,该字符将转换为整数值。 在文件处理的情况下,遇到文件结尾时它将返回EOF 。 如果有错误,则它还会返回EOF 。
C语言中的putchar()示例 (putchar() example in C)
#include <stdio.h>
#include <stdlib.h>
int main(){
//Initialize the character array
char str[100];
int i=0,j=0;
printf("Enter the string into the file\n");
//takes all the characters until enter is pressed
while((str[i]=getchar())!='\n'){
//increment the index of the character array
i++;
}
//after taking all the character add
//null pointer at the end of the string
str[i]='\0';
printf("\nThe file content is - ");
//loop is break when null pointer is encountered
while(str[j]!='\0'){
//print the characters
putchar(str[j]);
j++;
}
return 0;
}
Output
输出量
翻译自: https://www.includehelp.com/c-programs/putchar-function-in-c-language-with-example.aspx
c语言putchar函数