, please notify me in time and I will correct them in time to avoid misleading everyone. Thank you very much ^_^
[No.1 difference between the sizeof keyword and strlen in determining the length of a C string]
[Question No. 1]Enter the values of the following expressions in sequence (values: errors and uncertain values ):Copy content to clipboardCode:
Char * str_1 = "12345 ";Char str_2 [] = "12345 ";Char str_3 [5] = {'1 '};Char str_4 [5] = {'1', '2', '
sizeof function:The number of bytes, such as the int type is 4 bytes under the 32 platform, Char is 1 bytes, and any type of pointer is 4 bytes.Stelen function:The length of the string, not including '/'.The following is an example of distinguishing two functions from one-dimensional and two-dimensional arrays:(1) One-dimensional arraysint a[] = {1, 2, 3, 4};printf ("%d\n", sizeof (a)); printf ("%d\n", sizeof (A + 0));p rintf ("%d\n", sizeof (*a));p rintf ("%d\n", sizeof (A + 1));p rintf ("%d\n"
1. strcat -- string connection
1 #include
※Note: the first string array must be large enough; otherwise, an out-of-bounds problem may occur.
2. strcpy -- Copy strings
1 #include
※Note: the first string array must be large enough; otherwise, an out-of-bounds problem may occur. The second parameter can be an array or a character.
3. strcmp -- string comparison Function
1 #include
※Note: if the former is large, 1 is returned. If the latter is large,-1 is returned. If the former is equal, 0 is
/************************* @ Author: weedge @ Date: 21/07/2011 @ comment: 1. implement strlen without local and global variables; for more information, see ************************************** * ***/# include
Write this sectionProgramOne student asked me how the send function in Winsock sent an int value. I checked the send prototype.
Int send (socketS,Const char far* Buf,IntLen,IntFlags);
WhereThe second parameter must be a string pointer.. So I thought about howConverts an int value to a string.As a result, the following section is written:Code.
/***************************************. C * One program which contains ITOA (,); strlen (..); functi
In the forum to see a predecessor of the face of the question, the exact words are said
"One of the problems encountered during the interview was that it was not allowed to call the library function, and it was not allowed to write int strlen (char *strdest) with any global or local variables; ", inadvertently see, they think for a while, no ideas, and then sorted out the reply to the cattle, I think the use of recursive method to solve this problem,
Write Functions in C language to implement strlen's function of calculating the string lengthThis article introduces three methods: 1. Cyclic notation (set a counter ). 2. Recursive Method, (function call itself for calculation) 3. pointer-pointer
Problem:
Evaluate the number (including spaces) of characters contained in a string, that is, evaluate the string length;
# Include # include int _ strlen (const char * Str) {assert (STR! = NULL); int I = 0; For (; * STR ++! = '\ 0'; I ++); //
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.