포인터 문자열 연결

 

/* 
  • * 프로그램의 저작권 및 버 전 설명 부분 

  • * Copyright (c)2013, 연대 컴퓨터 대학 학생 
  • * All rightsreserved. 

  • * 파일 이름: date.cpp                            
  • * 하 다.    자:                             

  • * 완료 날짜:  년.  월.   해. 
  • * 버 전 번호: v1.0       

  • * 입력 설명: 년 월 일 
  • * 질문 설명: 출력 에 대응 하 는 날 은 이 해 의 며칠 째 입 니 다. 

  • * 출력: 며칠 째 
  • */  
    
    #include <iostream>
    using namespace std;
    char * stringcat(char *source, const char *dest);
    int main() {
      char s1[30]="I love ";
      char *s2="C++";
      stringcat(s1,s2);
      cout<<s1<<endl;
      return 0;
    }
    char * stringcat(char *source, const char *dest)
    {
    	//    dest      source   
         char *p;    
        int i;    
        for(p=source;*p!='\0';p++);   
    		for(i=0;dest[i]!='\0';i++,p++)    
    		{      
            *p=dest[i];    
    		}    
        *p='\0';  
        return 0;  
    }
    
  • 좋은 웹페이지 즐겨찾기