Update 动态数组.cpp
This commit is contained in:
		@@ -1,5 +1,14 @@
 | 
				
			|||||||
#include<iostream>
 | 
					#include<iostream>
 | 
				
			||||||
char *sPtr;        		//<2F><><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>       
 | 
					#include<cstring>
 | 
				
			||||||
s="<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"      
 | 
					
 | 
				
			||||||
sPtr = new char[strlen(s)+1];
 | 
					
 | 
				
			||||||
strncpy(sPtr,s;  
 | 
					int main() {
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  char *sPtr;        	 
 | 
				
			||||||
 | 
					  const char* s="hello";
 | 
				
			||||||
 | 
					  sPtr = new char[strlen(s)+1];
 | 
				
			||||||
 | 
					  strncpy(sPtr,s,strlen(s)); 
 | 
				
			||||||
 | 
					  std::cout << sPtr << std::endl;
 | 
				
			||||||
 | 
					  delete sPtr;
 | 
				
			||||||
 | 
					  return  0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user