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
Changes the size of a file. A more secure version is available; see [_chsize_s](../../c-runtime-library/reference/chsize-s.md).
25
-
26
-
## Syntax
27
-
28
-
```
29
-
int _chsize(
30
-
int fd,
31
-
long size
32
-
);
33
-
```
34
-
35
-
#### Parameters
36
-
`fd`
37
-
File descriptor referring to an open file.
38
-
39
-
`size`
40
-
New length of the file in bytes.
41
-
42
-
## Return Value
43
-
`_chsize` returns the value 0 if the file size is successfully changed. A return value of -1 indicates an error: `errno` is set to `EACCES` if the specified file is locked against access, to `EBADF` if the specified file is read-only or the descriptor is invalid, `ENOSPC` if no space is left on the device, or `EINVAL` if `size` is less than zero.
44
-
45
-
See [_doserrno, errno, _sys_errlist, and _sys_nerr](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md) for more information on these, and other, return codes.
46
-
47
-
## Remarks
48
-
The `_chsize` function extends or truncates the file associated with `fd` to the length specified by `size`. The file must be open in a mode that permits writing. Null characters ('\0') are appended if the file is extended. If the file is truncated, all data from the end of the shortened file to the original length of the file is lost.
49
-
50
-
This function validates its parameters. If `size` is less than zero or `fd` is a bad file descriptor, the invalid parameter handler is invoked, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md).
Changes the size of a file. A more secure version is available; see [_chsize_s](../../c-runtime-library/reference/chsize-s.md).
23
+
24
+
## Syntax
25
+
26
+
```C
27
+
int_chsize(
28
+
int fd,
29
+
long size
30
+
);
31
+
```
32
+
33
+
### Parameters
34
+
*fd*<br/>
35
+
File descriptor referring to an open file.
36
+
37
+
*size*<br/>
38
+
New length of the file in bytes.
39
+
40
+
## Return Value
41
+
42
+
_chsize` returns the value 0 if the file size is successfully changed. A return value of -1 indicates an error: `errno` is set to `EACCES` if the specified file is read-only or the specified file is locked against access, to `EBADF` if the descriptor is invalid, `ENOSPC` if no space is left on the device, or `EINVAL` if `size` is less than zero.
43
+
44
+
See [_doserrno, errno, _sys_errlist, and _sys_nerr](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md) for more information on these, and other, return codes.
45
+
46
+
## Remarks
47
+
48
+
The `_chsize` function extends or truncates the file associated with `fd` to the length specified by `size`. The file must be open in a mode that permits writing. Null characters ('\0') are appended if the file is extended. If the file is truncated, all data from the end of the shortened file to the original length of the file is lost.
49
+
50
+
This function validates its parameters. If `size` is less than zero or `fd` is a bad file descriptor, the invalid parameter handler is invoked, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md).
0 commit comments