[Daily development] Common DOS commands and character library notes

Common DOS commands
d: drive letter switching
dir list files and folders in the current directory
md create a directory (folder)
rd delete an empty directory 
rd /s delete a directory with content (ask whether to delete)
rd /s delete a directory with content Directory
cd Enter the specified directory
cd.. Go back to the first level directory
cd\ Go back to the root directory
del Delete the file
cls Clear the screen
exit Exit dos 


//************************************Gorgeous dividing line*********** ************************//


strstr function prototype: char * strstr(char * str1, char * str2);
the name of the library: #include <string.h>
The function is to find out the position of the string str2 in the string str1 for the first time (that is, It is said that the string sr1 should contain the string str2), if it is found, it will return the pointer of the position of the string (that is, the position of the address of the string str2 in the string str1), and if it is not found, it will return a null pointer (that is, null ).
For example the following code:
#include "string.h"
void main()
{
	char p[] = "URIEN->MARS_TECH";
	char *str = strstr(p,"MARS");
	printf(str);
}
The results are as follows:
MARS_TECH
Function prototype: extern char *strchr(char *str, char character)
Parameter description: str is a pointer to a string, and character is a character to be searched.       
Library name: #include <string.h>
Function: Find the first occurrence of the character character from the string str. 
Return description: Returns a pointer to the position of the first character character, or NULL if not found.
Other notes: There is also a format char *strchr( const char *string, int c ), where the string is given in int type.


For example the following code:
#include "string.h"

void main()
{
	char p[] = "URIEN->MARS_TECH";
	char *str = strstr(p,'M');
	printf(str);
}
The results are as follows:
MARS_TECH
Usage of the sprintf function
This function is included in the header file of stdio.h. When using it, you need to add: #include <stdio.h>
sprintf and printf function are similar in function.
The sprintf function converts other data types into string types when we complete the conversion. is widely used in operation.
The format of the sprintf function: int sprintf( char *buffer, const char *format [, argument,...] );
Except the first two parameters are fixed, the optional parameters can be any number. buffer is the character array name; format is the format string

The return value of sprintf is the number of characters in the character array, that is, the length of the string. It is not necessary to call strlen(s) to find the length of the string.


By Urien April 11, 2018 18:07:29

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325858908&siteId=291194637
Recommended