Home>Article>Backend Development> What does console.WriteLine mean in c language?

What does console.WriteLine mean in c language?

青灯夜游
青灯夜游 Original
2020-08-31 14:28:38 15126browse

console.WriteLine refers to output to the screen. It is often used in console programs. The output content is one line. The Console.WriteLine() method outputs the string to be output together with the newline control character. When the statement is executed, the cursor will move to the next line of the currently output string.

What does console.WriteLine mean in c language?

##Console.Write() and Console.WriteLine() are both methods provided by System.Console. They are mainly used to convert the output stream to the specified output. The device (default is the screen) is displayed.


The difference between the two is that the Console.WriteLine() method outputs the string to be output together with the newline control character. When the statement is executed, The cursor will move to the next line of the current output string.

As for the Console.Write() method, the cursor will stop after the last character of the output string and will not move to the next line.

For example,

Console.WriteLine("a");Console.WriteLine("b")

will be output on 2 lines


a b

and

Console.Write("a");Console.Write("b")

will be output on the same line

a b

Use line break output: Console.WriteLine

Use non-line break output: Console.Write

The code is as follows

// 在控制台上打印 Hello World! Console.WriteLine("Hello World !"); //换行打印 Console.Write("hello"); //不换行打印 Console.Write("--"); Console.Write("world"); Console.ReadKey();//ReadKey()运行完结果不退出控制台

What does console.WriteLine mean in c language?

C# console Input/output statement

Console.Read() method: Read a character from the console window and return an int value

Console.ReadLine() method: Read from the console window Take a line of text and return the string value

Console.ReadKey() method: Monitor keyboard events, which can be understood as pressing any key to execute the

Console.Write() method: Write the specified value Console window

Console.WriteLine() method: Write the specified value to the console window, but add a newline character

at the end of the output result where you want to break the line "\r \n”

What does console.WriteLine mean in c language?

Related recommendations:

c language tutorial video

The above is the detailed content of What does console.WriteLine mean 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