You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/c-language/addition-plus.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,11 @@ ms.author: "mblome"
12
12
ms.workload: ["cplusplus"]
13
13
---
14
14
# Addition (+)
15
-
The addition operator (**+**) causes its two operands to be added. Both operands can be either integral or floating types, or one operand can be a pointer and the other an integer.
16
-
17
-
When an integer is added to a pointer, the integer value (*i*) is converted by multiplying it by the size of the value that the pointer addresses. After conversion, the integer value represents *i* memory positions, where each position has the length specified by the pointer type. When the converted integer value is added to the pointer value, the result is a new pointer value representing the address *i* positions from the original address. The new pointer value addresses a value of the same type as the original pointer value and therefore is the same as array indexing (see [One-Dimensional Arrays](../c-language/one-dimensional-arrays.md) and [Multidimensional Arrays](../c-language/multidimensional-arrays-c.md)). If the sum pointer points outside the array, except at the first location beyond the high end, the result is undefined. For more information, see [Pointer Arithmetic](../c-language/pointer-arithmetic.md).
The addition operator (**+**) causes its two operands to be added. Both operands can be either integral or floating types, or one operand can be a pointer and the other an integer.
17
+
18
+
When an integer is added to a pointer, the integer value (*i*) is converted by multiplying it by the size of the value that the pointer addresses. After conversion, the integer value represents *i* memory positions, where each position has the length specified by the pointer type. When the converted integer value is added to the pointer value, the result is a new pointer value representing the address *i* positions from the original address. The new pointer value addresses a value of the same type as the original pointer value and therefore is the same as array indexing (see [One-Dimensional Arrays](../c-language/one-dimensional-arrays.md) and [Multidimensional Arrays](../c-language/multidimensional-arrays-c.md)). If the sum pointer points outside the array, except at the first location beyond the high end, the result is undefined. For more information, see [Pointer Arithmetic](../c-language/pointer-arithmetic.md).
Copy file name to clipboardExpand all lines: docs/c-language/allocating-zero-memory.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,11 @@ ms.author: "mblome"
12
12
ms.workload: ["cplusplus"]
13
13
---
14
14
# Allocating Zero Memory
15
-
**ANSI 4.10.3** The behavior of the `calloc`, `malloc`, or `realloc` function if the size requested is zero
16
-
17
-
The `calloc`, `malloc`, and `realloc` functions accept zero as an argument. No actual memory is allocated, but a valid pointer is returned and the memory block can be modified later by realloc.
**ANSI 4.10.3** The behavior of the `calloc`, `malloc`, or `realloc` function if the size requested is zero
17
+
18
+
The `calloc`, `malloc`, and `realloc` functions accept zero as an argument. No actual memory is allocated, but a valid pointer is returned and the memory block can be modified later by realloc.
Copy file name to clipboardExpand all lines: docs/c-language/ansi-conformance.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,11 @@ ms.author: "mblome"
12
12
ms.workload: ["cplusplus"]
13
13
---
14
14
# ANSI Conformance
15
-
Microsoft C conforms to the standard for the C language as set forth in the 9899:1990 edition of the ANSI C standard.
16
-
17
-
Microsoft extensions to the ANSI C standard are noted in the text and syntax of this book as well as in the online reference. Because the extensions are not a part of the ANSI C standard, their use may restrict portability of programs between systems. By default, the Microsoft extensions are enabled. To disable the extensions, specify the /Za compiler option. With /Za, all non-ANSI code generates errors or warnings.
18
-
19
-
## See Also
20
-
[Organization of the C Language Reference](../c-language/organization-of-the-c-language-reference.md)
15
+
16
+
Microsoft C conforms to the standard for the C language as set forth in the 9899:1990 edition of the ANSI C standard.
17
+
18
+
Microsoft extensions to the ANSI C standard are noted in the text and syntax of this book as well as in the online reference. Because the extensions are not a part of the ANSI C standard, their use may restrict portability of programs between systems. By default, the Microsoft extensions are enabled. To disable the extensions, specify the /Za compiler option. With /Za, all non-ANSI code generates errors or warnings.
19
+
20
+
## See Also
21
+
22
+
[Organization of the C Language Reference](../c-language/organization-of-the-c-language-reference.md)
Copy file name to clipboardExpand all lines: docs/c-language/argument-description.md
+20-17Lines changed: 20 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,20 +12,23 @@ ms.author: "mblome"
12
12
ms.workload: ["cplusplus"]
13
13
---
14
14
# Argument Description
15
-
The `argc` parameter in the **main** and **wmain** functions is an integer specifying how many arguments are passed to the program from the command line. Since the program name is considered an argument, the value of `argc` is at least one.
16
-
17
-
## Remarks
18
-
The `argv` parameter is an array of pointers to null-terminated strings representing the program arguments. Each element of the array points to a string representation of an argument passed to **main** (or **wmain**). (For information about arrays, see [Array Declarations](../c-language/array-declarations.md).) The `argv` parameter can be declared either as an array of pointers to type `char` (`char *argv[]`) or as a pointer to pointers to type `char` (`char **argv`). For **wmain**, the `argv` parameter can be declared either as an array of pointers to type `wchar_t` (`wchar_t *argv[]`) or as a pointer to pointers to type `wchar_t` (`wchar_t **argv`).
19
-
20
-
By convention, `argv`**[0]** is the command with which the program is invoked. However, it is possible to spawn a process using [CreateProcess](/windows/desktop/api/processthreadsapi/nf-processthreadsapi-createprocessa) and if you use both the first and second arguments (`lpApplicationName` and `lpCommandLine`), `argv`**[0]** may not be the executable name; use [GetModuleFileName](https://msdn.microsoft.com/library/windows/desktop/ms683197) to retrieve the executable name.
21
-
22
-
The last pointer (`argv[argc]`) is **NULL**. (See [getenv](../c-runtime-library/reference/getenv-wgetenv.md) in the *Run-Time Library Reference* for an alternative method for getting environment variable information.)
23
-
24
-
**Microsoft Specific**
25
-
26
-
The `envp` parameter is a pointer to an array of null-terminated strings that represent the values set in the user's environment variables. The `envp` parameter can be declared as an array of pointers to `char` (`char *envp[]`) or as a pointer to pointers to `char` (`char **envp`). In a **wmain** function, the `envp` parameter can be declared as an array of pointers to `wchar_t` (`wchar_t *envp[]`) or as a pointer to pointers to `wchar_t` (`wchar_t **envp`). The end of the array is indicated by a **NULL**\*pointer. Note that the environment block passed to **main** or **wmain** is a "frozen" copy of the current environment. If you subsequently change the environment via a call to _**putenv** or `_wputenv`, the current environment (as returned by `getenv`/`_wgetenv` and the `_environ` or `_wenviron` variables) will change, but the block pointed to by `envp` will not change. The `envp` parameter is ANSI compatible in C, but not in C++.
27
-
28
-
**END Microsoft Specific**
29
-
30
-
## See Also
31
-
[main Function and Program Execution](../c-language/main-function-and-program-execution.md)
15
+
16
+
The `argc` parameter in the **main** and **wmain** functions is an integer specifying how many arguments are passed to the program from the command line. Since the program name is considered an argument, the value of `argc` is at least one.
17
+
18
+
## Remarks
19
+
20
+
The `argv` parameter is an array of pointers to null-terminated strings representing the program arguments. Each element of the array points to a string representation of an argument passed to **main** (or **wmain**). (For information about arrays, see [Array Declarations](../c-language/array-declarations.md).) The `argv` parameter can be declared either as an array of pointers to type `char` (`char *argv[]`) or as a pointer to pointers to type `char` (`char **argv`). For **wmain**, the `argv` parameter can be declared either as an array of pointers to type `wchar_t` (`wchar_t *argv[]`) or as a pointer to pointers to type `wchar_t` (`wchar_t **argv`).
21
+
22
+
By convention, `argv`**[0]** is the command with which the program is invoked. However, it is possible to spawn a process using [CreateProcess](/windows/desktop/api/processthreadsapi/nf-processthreadsapi-createprocessa) and if you use both the first and second arguments (`lpApplicationName` and `lpCommandLine`), `argv`**[0]** may not be the executable name; use [GetModuleFileName](https://msdn.microsoft.com/library/windows/desktop/ms683197) to retrieve the executable name.
23
+
24
+
The last pointer (`argv[argc]`) is **NULL**. (See [getenv](../c-runtime-library/reference/getenv-wgetenv.md) in the *Run-Time Library Reference* for an alternative method for getting environment variable information.)
25
+
26
+
**Microsoft Specific**
27
+
28
+
The `envp` parameter is a pointer to an array of null-terminated strings that represent the values set in the user's environment variables. The `envp` parameter can be declared as an array of pointers to `char` (`char *envp[]`) or as a pointer to pointers to `char` (`char **envp`). In a **wmain** function, the `envp` parameter can be declared as an array of pointers to `wchar_t` (`wchar_t *envp[]`) or as a pointer to pointers to `wchar_t` (`wchar_t **envp`). The end of the array is indicated by a **NULL**\*pointer. Note that the environment block passed to **main** or **wmain** is a "frozen" copy of the current environment. If you subsequently change the environment via a call to _**putenv** or `_wputenv`, the current environment (as returned by `getenv`/`_wgetenv` and the `_environ` or `_wenviron` variables) will change, but the block pointed to by `envp` will not change. The `envp` parameter is ANSI compatible in C, but not in C++.
29
+
30
+
**END Microsoft Specific**
31
+
32
+
## See Also
33
+
34
+
[main Function and Program Execution](../c-language/main-function-and-program-execution.md)
Copy file name to clipboardExpand all lines: docs/c-language/arguments-to-main.md
+26-24Lines changed: 26 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,27 +11,29 @@ ms.author: "mblome"
11
11
ms.workload: ["cplusplus"]
12
12
---
13
13
# Arguments to main
14
-
**ANSI 2.1.2.2.1** The semantics of the arguments to main
15
-
16
-
In Microsoft C, the function called at program startup is called **main**. There is no prototype declared for **main**, and it can be defined with zero, two, or three parameters:
17
-
18
-
```
19
-
int main( void )
20
-
int main( int argc, char *argv[] )
21
-
int main( int argc, char *argv[], char *envp[] )
22
-
```
23
-
24
-
The third line above, where **main** accepts three parameters, is a Microsoft extension to the ANSI C standard. The third parameter, **envp**, is an array of pointers to environment variables. The **envp** array is terminated by a null pointer. See [The main Function and Program Execution](../c-language/main-function-and-program-execution.md) for more information about **main** and **envp**.
25
-
26
-
The variable **argc** never holds a negative value.
27
-
28
-
The array of strings ends with **argv[argc]**, which contains a null pointer.
29
-
30
-
All elements of the **argv** array are pointers to strings.
31
-
32
-
A program invoked with no command-line arguments will receive a value of one for **argc**, as the name of the executable file is placed in **argv[0]**. (In MS-DOS versions prior to 3.0, the executable-file name is not available. The letter "C" is placed in **argv[0]**.) Strings pointed to by **argv[1]** through **argv[argc - 1]** represent program parameters.
33
-
34
-
The parameters **argc** and **argv** are modifiable and retain their last-stored values between program startup and program termination.
35
-
36
-
## See Also
37
-
[Environment](../c-language/environment.md)
14
+
15
+
**ANSI 2.1.2.2.1** The semantics of the arguments to main
16
+
17
+
In Microsoft C, the function called at program startup is called **main**. There is no prototype declared for **main**, and it can be defined with zero, two, or three parameters:
18
+
19
+
```
20
+
int main( void )
21
+
int main( int argc, char *argv[] )
22
+
int main( int argc, char *argv[], char *envp[] )
23
+
```
24
+
25
+
The third line above, where **main** accepts three parameters, is a Microsoft extension to the ANSI C standard. The third parameter, **envp**, is an array of pointers to environment variables. The **envp** array is terminated by a null pointer. See [The main Function and Program Execution](../c-language/main-function-and-program-execution.md) for more information about **main** and **envp**.
26
+
27
+
The variable **argc** never holds a negative value.
28
+
29
+
The array of strings ends with **argv[argc]**, which contains a null pointer.
30
+
31
+
All elements of the **argv** array are pointers to strings.
32
+
33
+
A program invoked with no command-line arguments will receive a value of one for **argc**, as the name of the executable file is placed in **argv[0]**. (In MS-DOS versions prior to 3.0, the executable-file name is not available. The letter "C" is placed in **argv[0]**.) Strings pointed to by **argv[1]** through **argv[argc - 1]** represent program parameters.
34
+
35
+
The parameters **argc** and **argv** are modifiable and retain their last-stored values between program startup and program termination.
0 commit comments