String output function puts () fputs () printf () __ function

Source: Internet
Author: User
Tags define function

The C language has three standard library functions that are bold to output strings puts () fputs () printf ()

The use of the puts () function is simple and requires only the address of the string parameter. Note that each string is displayed in a single line, and unlike printf (), puts () automatically adds a newline character after the string is displayed.

/* put_out.c-using puts ()/#include <stdio.h> #define DEF "I am a #defined string." int main (void) {char str1[ [] = "An array is initialized to me." const char * str2 = "A pointer is initialized to me." Puts ("I ' m an argument to puts ()"); Puts (DEF); Puts (STR1); Puts (STR2); Puts (&str1[5]); Puts (str2+4); return 0; }

Run results

I ' m an argument to puts ().
I am a #defined string.
An array is initialized to me.
A pointer is initialized to me.
Ray is initialized to me.
Inter is initialized to me.

Fputs ()---is a file-oriented version of Gets ()

Define function fputs (const char *s, FILE *stream)

The return value succeeds returns the number of characters written, and the return EOF indicates an error occurred

Used to write the string that the argument s refers to in the file that the parameter stream refers to.

Format output for printf ()---string

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.