Home>Article>Backend Development> What symbols are used to output strings in C language?

What symbols are used to output strings in C language?

王林
王林 Original
2020-06-19 15:03:09 14819browse

What symbols are used to output strings in C language?

#Use double quotes in C language to output strings.

(Recommended tutorial:c language tutorial)

Detailed interpretation:

In C language, there are two functions that can be controlled Output strings on the computer (monitor), they are:

puts(): Output strings and automatically wrap lines. This function can only output strings.

printf(): Outputs a string through the format control character %s, and cannot automatically wrap lines. In addition to strings, printf() can also output other types of data.

For example:

#include  int main(){ char str[] = "http://c.bian"; printf("%s\n", str); //通过字符串名字输出 printf("%s\n", "http://c.bian"); //直接输出 puts(str); //通过字符串名字输出 puts("http://c.bian"); //直接输出 return 0; }

Note that when outputting a string, you only need to give the name, without the following [ ]. For example, the following two ways of writing are wrong:

printf("%s\n", str[]); puts(str[10]);

The above is the detailed content of What symbols are used to output strings in C language?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn