Home Backend Development C#.Net Tutorial Can comments in a C program only be one line?

Can comments in a C program only be one line?

Jun 18, 2020 am 11:58 AM
c program Comment

Can comments in a C program only be one line?

#Can comments in a C program only be one line?

The comments of a C program may not be one line. There are multiple lines of comments in a C program. The usage is a block comment starting with /* and ending with */;

The other is starting with // and ending with a newline character. The closing line comment.

You can use the /* and */ delimiters to mark comments within one line, or to mark comments on multiple lines .

For example, in the following function prototype, the ellipsis means that the open() function has a third parameter, which is optional.

Comments explain the usage of this optional parameter:

1

int open( const char *name, int mode, … /* int permissions */ );

Copy after login

C language add comments

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

#include<stdio.h>

#include<string.h>

#include<stdlib.h>

intmain()

{

intm,k=1,n;

charline1[256],line[256];//将文件中的数据读入到字符数组中

FILE*fpin=fopen("sourcefile.c","r");

if(fpin==NULL)

{

printf("sourcecodereaderror!\n");

exit(1);

}

FILE*fpout=fopen("targetfile.c","w+");

if(fpout==NULL)

{

printf("sourcecodewriteerror!\n");

exit(1);

}

printf("请输入m和n:");

scanf("%d%d",&m,&n);

intn1=0;

fgets(line1,255,fpin);

do

{

n1++;

if(n1>=m&&n1<m+k)

fputs("//",fpout);

fputs(line1,fpout);

fgets(line1,255,fpin);

}

while(!feof(fpin));

fseek(fpout,0,SEEK_SET);

fgets(line,255,fpout);

do

{

printf("%d\t%s",k,line);

k++;

fgets(line,255,fpout);

}

while(!feof(fpout));

fclose(fpout);

fclose(fpin);

return0;

Copy after login

Recommended tutorial: "C Language

The above is the detailed content of Can comments in a C program only be one line?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Conveniently use PyCharm shortcut keys to implement multi-line comments Conveniently use PyCharm shortcut keys to implement multi-line comments Jan 27, 2024 am 08:02 AM

PyCharm multi-line comment shortcut keys: Make code comments more convenient and require specific code examples. In daily programming work, code comments are a very important part. It not only improves the readability and maintainability of the code, but also helps other developers understand the intent and design ideas of the code. However, manually adding code comments is often a time-consuming and tedious task. In order to make our code comments more efficient, PyCharm provides shortcut keys for multi-line comments. In PyCharm, we can use Ctrl+/

How to Optimize the Maintainability of Java Code: Experience and Advice How to Optimize the Maintainability of Java Code: Experience and Advice Nov 22, 2023 pm 05:18 PM

How to Optimize the Maintainability of Java Code: Experience and Advice In the software development process, writing code with good maintainability is crucial. Maintainability means that code can be easily understood, modified, and extended without causing unexpected problems or additional effort. For Java developers, how to optimize the maintainability of code is an important issue. This article will share some experiences and suggestions to help Java developers improve the maintainability of their code. Following standardized naming rules can make the code more readable.

How to add notes to saved passwords on iPhone How to add notes to saved passwords on iPhone Feb 28, 2024 pm 07:41 PM

iCloud Keychain makes it easier to manage your passwords without relying on memorizing or guessing website or usernames. You can do this by adding notes to existing passwords for apps and websites in iCloud Keychain. In this post, we will explain how to add notes to the passwords you save in iCloud Keychain on iPhone. Requirements There are some requirements you need to meet to use this new feature in iCloud Keychain. iPhone running iOS 15.4 or later Passwords stored in iCloud Keychain A valid Apple ID A valid internet connection How to add notes to saved passwords It goes without saying that you should store some passwords in iCloud Keychain

C++ program to find the value of the inverse hyperbolic sine function taking a given value as argument C++ program to find the value of the inverse hyperbolic sine function taking a given value as argument Sep 17, 2023 am 10:49 AM

Hyperbolic functions are defined using hyperbolas instead of circles and are equivalent to ordinary trigonometric functions. It returns the ratio parameter in the hyperbolic sine function from the supplied angle in radians. But do the opposite, or in other words. If we want to calculate an angle from a hyperbolic sine, we need an inverse hyperbolic trigonometric operation like the hyperbolic inverse sine operation. This course will demonstrate how to use the hyperbolic inverse sine (asinh) function in C++ to calculate angles using the hyperbolic sine value in radians. The hyperbolic arcsine operation follows the following formula -$$\mathrm{sinh^{-1}x\:=\:In(x\:+\:\sqrt{x^2\:+\:1})}, Where\:In\:is\:natural logarithm\:(log_e\:k)

C++ program to print dictionary C++ program to print dictionary Sep 11, 2023 am 10:33 AM

A map is a special type of container in C++ in which each element is a pair of two values, namely a key value and a map value. The key value is used to index each item, and the mapped value is the value associated with the key. Regardless of whether the mapped value is unique, the key is always unique. To print map elements in C++ we have to use iterator. An element in a set of items is indicated by an iterator object. Iterators are primarily used with arrays and other types of containers (such as vectors), and they have a specific set of operations that can be used to identify specific elements within a specific range. Iterators can be incremented or decremented to reference different elements present in a range or container. The iterator points to the memory location of a specific element in the range. Printing a map in C++ using iterators First, let's look at how to define

C program uses rename() function to change file name C program uses rename() function to change file name Sep 21, 2023 pm 10:01 PM

The rename function changes a file or directory from its old name to its new name. This operation is similar to the move operation. So we can also use this rename function to move files. This function exists in the stdio.h library header file. The syntax of the rename function is as follows: intrename(constchar*oldname,constchar*newname); The function of the rename() function accepts two parameters. One is oldname and the other is newname. Both parameters are pointers to constant characters that define the old and new names of the file. Returns zero if the file was renamed successfully; otherwise, returns a nonzero integer. During a rename operation

PyCharm Annotation Operation Guide: Optimizing the Code Writing Experience PyCharm Annotation Operation Guide: Optimizing the Code Writing Experience Feb 21, 2024 pm 06:27 PM

PyCharm Comment Operation Guide: Optimizing the Code Writing Experience In daily code writing, comments are a very important part. Good comments not only improve the readability of your code, but also help other developers better understand and maintain the code. As a powerful Python integrated development environment, PyCharm also provides rich functions and tools in terms of annotation, which can greatly optimize the code writing experience. This article will introduce how to perform annotation operations in PyCharm and how to utilize PyCharm's annotations.

C++ program to check if a character is alphabetic or non-alphabetic C++ program to check if a character is alphabetic or non-alphabetic Sep 14, 2023 pm 03:37 PM

Using strings or characters is sometimes very useful when solving some logic programming problems. A string is a collection of characters, which is a 1-byte data type used to hold symbols in ASCII values. Symbols can be English letters, numbers, or special characters. In this article, we will learn how to check if a character is an English letter or a letter of the alphabet using C++. Checking the isalpha() function To check if a number is a letter, we can use the isalpha() function in the ctype.h header file. This takes a character as input and returns true if it is an alphabet, false otherwise. Let us look at the following C++ implementation to understand the usage of this function. The Chinese translation of Example is: show

See all articles