c语⾔putchar函数_C语⾔中的putchar()函数与⽰例
c语⾔putchar函数
C语⾔中的putchar()函数 (putchar() function in C)
putchar() function is defined in the <stdio.h> header file.
The putchar() function
putchar()函数
putchar()函数在<stdio.h>头⽂件中定义。
Prototype:
原型:
int putchar(const char *string);
Parameters: const char *string
Parameters:
参数: const char * string
参数:
Return type:
Return type: int
返回类型: int
返回类型:
Use of function:
使⽤功能:
putchar() function, we take the character to the stream stdout and store them into the
In the file handling, through the putchar() function
prototype of the function putchar() is int putchar(const char *string);
specified string array. The prototype of the function putchar()
原型是int
函数putchar()的原型putchar()函数 ,我们将字符带到流stdout并将其存储到指定的字符串数组中。 函数putchar()
在⽂件处理中,通过putchar()函数
putchar(const char * string);
The character which is read is an which is converted to an integer value. In the case of file handling, it returns when end-of-file is encountered. If there is an error then it also returns .
读取的字符是 ,该将转换为整数值。 在⽂件处理的情况下,遇到⽂件结尾时它将返回 。 如果有错误,则它还会返回 。
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++;
c语言char的用法}
return 0;
}
Output
输出量
c语⾔putchar函数
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论