Strings
We will show just one small part of string, and with more details in rate number 2 in Microsam Academy. Exist difference how is the string defined in C and in C++.
In C the string is presented like rank of characters, which finished with “ \0 ”.
#include <iostream> int main() |
The program reads string of keyboard. But? Did you try to insert string joined of few words? What happens then? For example, I insert CODE THIS PC and how result I get CODE???
The cause of is that the operator for inserting >> stops with reading of keyboard when it comes on first gap place. One manner for resolving this nearly hard problem is to use one function of C++ library:
gets(array-name); |
Is defined in library ( cstdio ). This function reads from the keyboard while you press ENTER.
#include <iostream> int main() |
Exist few functions for manipulation with strings, but I won’t retain on them, I can just mention them:
strcpy(), strcat(), strlen(), strcmp()
0 comments:
Post a Comment