The difference between the Fgets function and the fputs function

Source: Internet
Author: User

#include <stdio.h>
#define MAXLINE 20


int main (void)
{
Char Line[maxline];


while (Fgets (Line,maxline,stdin)!=null && line[0]! = ' \ n ')


Fputs (line,stdout);
return 0;

}


The fgets () function is the address (char * type) used to store the input. The second argument is an integral type, which represents the maximum length of the input string. The last parameter is the file pointer, which points to the file to be read

Fgets (BUF,MAX,FP)


The fputs () function accepts two parameters, which in turn are the address of a string and a pointer to a file. It writes a string known as a string address pointer to the specified file . Unlike the puts () function, the fputs () function does not add a newline character when printed.

Fputs (BUF,FP);

Here buf is the address of the string, FP specifies the destination file



The difference between the Fgets function and the fputs function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.