August 2001
Beginner
482 pages
10h 52m
English
C++ inherits from C a library of functions for dealing with strings. Among the many functions provided are two for copying one string into another: strcpy() and strncpy(). strcpy() copies the entire contents of one string into a designated buffer. Listing 15.8 demonstrates its use.
0: // Listing 15.8 - Using strcpy()
1: #include <iostream>
2: #include <string.h>
3:
4: int main()
5: {
6: char String1[] = "No man is an island";
7: char String2[80];
8:
9: strcpy(String2,String1);
10:
11: std::cout << "String1: " << String1 << std::endl;
12: std::cout << "String2: " << String2 << std::endl;
13: return 0;
14: }
|
String1: No man is an island String2: No man is an island
The header file STRING.H ... |
Read now
Unlock full access