Skip to content

Commit 9b780c5

Browse files
authored
Merge pull request #3815 from MicrosoftDocs/master
10/5 AM Publishing
2 parents ad53b94 + 33c49bc commit 9b780c5

File tree

6 files changed

+103
-120
lines changed

6 files changed

+103
-120
lines changed

docs/atl-mfc-shared/reference/csimplestringt-class.md

Lines changed: 80 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
---
22
description: "Learn more about: CSimpleStringT Class"
33
title: "CSimpleStringT Class"
4-
ms.date: "10/18/2018"
4+
ms.date: 10/04/2021
55
f1_keywords: ["CSimpleStringT", "ATLSIMPSTR/ATL::CSimpleStringT", "ATLSIMPSTR/ATL::CSimpleStringT::PCXSTR", "ATLSIMPSTR/ATL::CSimpleStringT::PXSTR", "ATLSIMPSTR/ATL::CSimpleStringT::CSimpleStringT", "ATLSIMPSTR/ATL::CSimpleStringT::Append", "ATLSIMPSTR/ATL::CSimpleStringT::AppendChar", "ATLSIMPSTR/ATL::CSimpleStringT::CopyChars", "ATLSIMPSTR/ATL::CSimpleStringT::CopyCharsOverlapped", "ATLSIMPSTR/ATL::CSimpleStringT::Empty", "ATLSIMPSTR/ATL::CSimpleStringT::FreeExtra", "ATLSIMPSTR/ATL::CSimpleStringT::GetAllocLength", "ATLSIMPSTR/ATL::CSimpleStringT::GetAt", "ATLSIMPSTR/ATL::CSimpleStringT::GetBuffer", "ATLSIMPSTR/ATL::CSimpleStringT::GetBufferSetLength", "ATLSIMPSTR/ATL::CSimpleStringT::GetLength", "ATLSIMPSTR/ATL::CSimpleStringT::GetManager", "ATLSIMPSTR/ATL::CSimpleStringT::GetString", "ATLSIMPSTR/ATL::CSimpleStringT::IsEmpty", "ATLSIMPSTR/ATL::CSimpleStringT::LockBuffer", "ATLSIMPSTR/ATL::CSimpleStringT::Preallocate", "ATLSIMPSTR/ATL::CSimpleStringT::ReleaseBuffer", "ATLSIMPSTR/ATL::CSimpleStringT::ReleaseBufferSetLength", "ATLSIMPSTR/ATL::CSimpleStringT::SetAt", "ATLSIMPSTR/ATL::CSimpleStringT::SetManager", "ATLSIMPSTR/ATL::CSimpleStringT::SetString", "ATLSIMPSTR/ATL::CSimpleStringT::StringLength", "ATLSIMPSTR/ATL::CSimpleStringT::Truncate", "ATLSIMPSTR/ATL::CSimpleStringT::UnlockBuffer"]
66
helpviewer_keywords: ["shared classes, CSimpleStringT", "strings [C++], ATL class", "CSimpleStringT class"]
7-
ms.assetid: 15814fcb-5b8f-4425-a97e-3b61fc9b48d8
87
---
98
# `CSimpleStringT` Class
109

1110
This class represents a `CSimpleStringT` object.
1211

1312
## Syntax
1413

15-
```
14+
```cpp
1615
template <typename BaseType>
1716
class CSimpleStringT
1817
```
@@ -122,6 +121,8 @@ Call this method to append an existing `CSimpleStringT` object to another `CSimp
122121
The following example demonstrates the use of `CSimpleStringT::Append`.
123122

124123
```cpp
124+
CAtlString basestr;
125+
IAtlStringMgr* pMgr = basestr.GetManager();
125126
CSimpleString str1(pMgr), str2(pMgr);
126127
str1.SetString(_T("Soccer is"));
127128
str2.SetString(_T(" an elegant game"));
@@ -154,7 +155,7 @@ Copies a character or characters to a `CSimpleStringT` object.
154155

155156
### Syntax
156157

157-
```
158+
```cpp
158159
static void CopyChars(
159160
XCHAR* pchDest,
160161
const XCHAR* pchSrc,
@@ -181,20 +182,29 @@ Call this method to copy characters from *`pchSrc`* to the *`pchDest`* string.
181182
The following example demonstrates the use of `CSimpleStringT::CopyChars`.
182183
183184
```cpp
185+
CAtlString basestr;
186+
IAtlStringMgr* pMgr = basestr.GetManager();
184187
CSimpleString str(_T("xxxxxxxxxxxxxxxxxxx"), 20, pMgr);
185-
TCHAR* pszSrc = _T("Hello world!");
188+
const TCHAR* pszSrc = _T("Hello world!");
186189
_tprintf_s(_T("%s\n"), str);
187-
str.CopyChars(str.GetBuffer(), pszSrc, 12);
190+
str.CopyChars(str.GetBuffer(), 20, pszSrc, 12);
188191
_tprintf_s(_T("%s\n"), str);
189192
```
190193

194+
The output from this example is as follows:
195+
196+
```output
197+
xxxxxxxxxxxxxxxxxxx
198+
Hello world!xxxxxxx
199+
```
200+
191201
## <a name="copycharsoverlapped"></a> `CSimpleStringT::CopyCharsOverlapped`
192202

193203
Copies a character or characters to a `CSimpleStringT` object.
194204

195205
### Syntax
196206

197-
```
207+
```cpp
198208
static void CopyCharsOverlapped(
199209
XCHAR* pchDest,
200210
const XCHAR* pchSrc,
@@ -226,7 +236,7 @@ Constructs a `CSimpleStringT` object.
226236
227237
### Syntax
228238
229-
```
239+
```cpp
230240
CSimpleStringT(const XCHAR* pchSrc, int nLength, IAtlStringMgr* pStringMgr);
231241
CSimpleStringT(PCXSTR pszSrc, IAtlStringMgr* pStringMgr);
232242
CSimpleStringT(const CSimpleStringT& strSrc);
@@ -259,6 +269,9 @@ Construct a new `CSimpleStringT` object. Because the constructors copy the input
259269
The following example demonstrates the use of `CSimpleStringT::CSimpleStringT` by using the ATL **`typedef`** `CSimpleString`. `CSimpleString` is a commonly used specialization of the class template `CSimpleStringT`.
260270

261271
```cpp
272+
CAtlString basestr;
273+
IAtlStringMgr* pMgr = basestr.GetManager();
274+
262275
CSimpleString s1(pMgr);
263276
// Empty string
264277
CSimpleString s2(_T("cat"), pMgr);
@@ -292,6 +305,9 @@ For more information, see [Strings: `CString` Exception Cleanup](../cstring-exce
292305
The following example demonstrates the use of `CSimpleStringT::Empty`.
293306

294307
```cpp
308+
CAtlString basestr;
309+
IAtlStringMgr* pMgr = basestr.GetManager();
310+
295311
CSimpleString s(pMgr);
296312
ASSERT(s.IsEmpty());
297313
```
@@ -351,7 +367,7 @@ Retrieves the allocated length of a `CSimpleStringT` object.
351367

352368
### Syntax
353369

354-
```
370+
```cpp
355371
int GetAllocLength() const throw();
356372
```
357373

@@ -369,7 +385,7 @@ Returns one character from a `CSimpleStringT` object.
369385

370386
### Syntax
371387

372-
```
388+
```cpp
373389
XCHAR GetAt(int iChar) const;
374390
```
375391
@@ -401,7 +417,7 @@ Returns a pointer to the internal character buffer for the `CSimpleStringT` obje
401417

402418
### Syntax
403419

404-
```
420+
```cpp
405421
PXSTR GetBuffer(int nMinBufferLength);
406422
PXSTR GetBuffer();
407423
```
@@ -450,7 +466,7 @@ Returns a pointer to the internal character buffer for the `CSimpleStringT` obje
450466

451467
### Syntax
452468

453-
```
469+
```cpp
454470
PXSTR GetBufferSetLength(int nLength);
455471
```
456472
@@ -507,7 +523,7 @@ Returns the number of characters in the `CSimpleStringT` object.
507523

508524
### Syntax
509525

510-
```
526+
```cpp
511527
int GetLength() const throw();
512528
```
513529

@@ -527,7 +543,7 @@ Retrieves the memory manager of the `CSimpleStringT` object.
527543

528544
### Syntax
529545

530-
```
546+
```cpp
531547
IAtlStringMgr* GetManager() const throw();
532548
```
533549

@@ -545,7 +561,7 @@ Retrieves the character string.
545561

546562
### Syntax
547563

548-
```
564+
```cpp
549565
PCXSTR GetString() const throw();
550566
```
551567

@@ -565,18 +581,26 @@ Call this method to retrieve the character string associated with the `CSimpleSt
565581
The following example demonstrates the use of `CSimpleStringT::GetString`.
566582

567583
```cpp
584+
CAtlString basestr;
585+
IAtlStringMgr* pMgr = basestr.GetManager();
568586
CSimpleString str(pMgr);
569587
str += _T("Cup soccer is best!");
570588
_tprintf_s(_T("%s"), str.GetString());
571589
```
572590
591+
The output from this example is as follows:
592+
593+
```output
594+
Cup soccer is best!
595+
```
596+
573597
## <a name="isempty"></a> `CSimpleStringT::IsEmpty`
574598

575599
Tests a `CSimpleStringT` object for the empty condition.
576600

577601
### Syntax
578602

579-
```
603+
```cpp
580604
bool IsEmpty() const throw();
581605
```
582606

@@ -603,7 +627,7 @@ Disables reference counting and protects the string in the buffer.
603627
604628
### Syntax
605629
606-
```
630+
```cpp
607631
PXSTR LockBuffer();
608632
```
609633

@@ -639,6 +663,9 @@ For more information about reference counting, see the following articles:
639663
The following example demonstrates the use of `CSimpleStringT::LockBuffer`.
640664

641665
```cpp
666+
CAtlString basestr;
667+
IAtlStringMgr* pMgr = basestr.GetManager();
668+
642669
CSimpleString str(_T("Hello"), pMgr);
643670
TCHAR ch;
644671

@@ -648,13 +675,19 @@ _tprintf_s(_T("%c"), ch);
648675
str.UnlockBuffer();
649676
```
650677
678+
The output from this example is as follows:
679+
680+
```output
681+
l
682+
```
683+
651684
## <a name="operator_at"></a> `CSimpleStringT::operator[]`
652685

653686
Call this function to access a single character of the character array.
654687

655688
### Syntax
656689

657-
```
690+
```cpp
658691
XCHAR operator[](int iChar) const;
659692
```
660693

@@ -685,7 +718,7 @@ Call this function to access a single character of the character array.
685718
686719
### Syntax
687720
688-
```
721+
```cpp
689722
XCHAR operator[](int iChar) const;
690723
```
691724

@@ -707,7 +740,7 @@ Joins a new string or character to the end of an existing string.
707740

708741
### Syntax
709742

710-
```
743+
```cpp
711744
CSimpleStringT& operator +=(PCXSTR pszSrc);
712745
CSimpleStringT& operator +=(const CSimpleStringT& strSrc);
713746
template<int t_nSize>
@@ -747,7 +780,7 @@ Assigns a new value to a `CSimpleStringT` object.
747780
748781
### Syntax
749782
750-
```
783+
```cpp
751784
CSimpleStringT& operator =(PCXSTR pszSrc);
752785
CSimpleStringT& operator =(const CSimpleStringT& strSrc);
753786
```
@@ -794,7 +827,7 @@ Directly accesses characters stored in a `CSimpleStringT` object as a C-style st
794827
795828
### Syntax
796829
797-
```
830+
```cpp
798831
operator PCXSTR() const throw();
799832
```
800833

@@ -846,7 +879,7 @@ A pointer to a constant string.
846879
847880
### Syntax
848881
849-
```
882+
```cpp
850883
typedef ChTraitsBase< BaseType >::PCXSTR PCXSTR;
851884
```
852885

@@ -876,19 +909,29 @@ Call this method to allocate a specific buffer size for the `CSimpleStringT` obj
876909
The following example demonstrates the use of `CSimpleStringT::Preallocate`.
877910
878911
```cpp
912+
CAtlString basestr;
913+
IAtlStringMgr* pMgr = basestr.GetManager();
914+
879915
CSimpleString str(pMgr);
880916
_tprintf_s(_T("Allocated length: %d\n"), str.GetAllocLength());
881917
str.Preallocate(100);
882918
_tprintf_s(_T("Allocated length: %d\n"), str.GetAllocLength());
883919
```
884920

921+
The output from this example is as follows:
922+
923+
```output
924+
Allocated length: 0
925+
Allocated length: 103
926+
```
927+
885928
## <a name="pxstr"></a> `CSimpleStringT::PXSTR`
886929

887930
A pointer to a string.
888931

889932
### Syntax
890933

891-
```
934+
```cpp
892935
typedef ChTraitsBase< BaseType >::PXSTR PXSTR;
893936
```
894937

@@ -1060,7 +1103,7 @@ Returns the number of characters in the specified string.
10601103
10611104
### Syntax
10621105
1063-
```
1106+
```cpp
10641107
ATL_NOINLINE static int StringLength(PCXSTR psz) throw();
10651108
```
10661109

@@ -1112,6 +1155,8 @@ Call this method to truncate the contents of the string to the new length.
11121155
The following example demonstrates the use of `CSimpleStringT::Truncate`.
11131156

11141157
```cpp
1158+
CAtlString basestr;
1159+
IAtlStringMgr* pMgr = basestr.GetManager();
11151160
CSimpleString str(_T("abcdefghi"), pMgr);
11161161
_tprintf_s(_T("Allocated length: %d\n"), str.GetLength());
11171162
_tprintf_s(_T("Contents: %s\n"), str);
@@ -1120,6 +1165,15 @@ _tprintf_s(_T("Allocated length: %d\n"), str.GetLength());
11201165
_tprintf_s(_T("Contents: %s\n"), str);
11211166
```
11221167
1168+
The output from this example is:
1169+
1170+
```Output
1171+
Allocated length: 9
1172+
Contents: abcdefghi
1173+
Allocated length: 4
1174+
Contents: abcd
1175+
```
1176+
11231177
## <a name="unlockbuffer"></a> `CSimpleStringT::UnlockBuffer`
11241178

11251179
Unlocks the buffer of the `CSimpleStringT` object.
@@ -1142,7 +1196,7 @@ Destroys a `CSimpleStringT` object.
11421196

11431197
### Syntax
11441198

1145-
```
1199+
```cpp
11461200
~CSimpleStringT() throw();
11471201
```
11481202

docs/c-runtime-library/reference/rand.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ int rand(void);
2727
2828
The **`rand`** function returns a pseudorandom integer in the range 0 to **`RAND_MAX`** (32767). Use the [`srand`](srand.md) function to seed the pseudorandom-number generator before calling **`rand`**.
2929
30-
The **`rand`** function generates a well-known sequence and isn't appropriate for use as a cryptographic function. For more cryptographically secure random number generation, use [`rand_s`](rand-s.md) or the functions declared in the C++ Standard Library in [`<random>`](../../standard-library/random.md). For information about what's wrong with **`rand`** and how `<random>` addresses these shortcomings, see this video entitled [rand Considered Harmful](https://channel9.msdn.com/Events/GoingNative/2013/rand-Considered-Harmful).
30+
The **`rand`** function generates a well-known sequence and isn't appropriate for use as a cryptographic function. For more cryptographically secure random number generation, use [`rand_s`](rand-s.md) or the functions declared in the C++ Standard Library in [`<random>`](../../standard-library/random.md).
3131
3232
By default, this function's global state is scoped to the application. To change this, see [Global state in the CRT](../global-state.md).
3333

docs/cpp/index.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ landingContent:
3333
url: ../build/vscpp-step-1-create.md
3434
- text: Create a console calculator in C++
3535
url: ../get-started/tutorial-console-cpp.md
36-
- linkListType: video
37-
links:
38-
- text: "Learn C++ - A general purpose language and library"
39-
url: https://channel9.msdn.com/Series/cplusplus-language-library
4036
- linkListType: learn
4137
links:
4238
- text: Welcome back to C++ - Modern C++

0 commit comments

Comments
 (0)