|
http://www.hackerschool.org/HS_Boards/zboard.php?AllArticle=true&no=2992 [복사]
php 코딩을 하다 열심히 배운 C를 까먹기전에 다시 한번 리뷰 하던중
갑자기 이해가 안돼는 부분 :(
#include <stdio.h>
#include <string.h>
void Replace(char *theString);
int main(){
char string[10] = "hello";
Replace(string);
puts(string);
}
void Replace(char *theString){
int len = strlen(*theString);
*theString[len -1] = '\0';
}
// string 에서 마지막 글자를 '\0' 로 바꾸는 건데요
함수 Replace 에 있는 두 *theString 들을 그냥 theString 으로 바꾸니 프로그램이 제대로 돌아가더군요 ....
왜 theString 이죠? 원래 theString은 "string" 의 주소를 가지고 있고 *theString 을 이용해야지 value 를 바꿀수
있는거 아닌가요? |
Hit : 4514 Date : 2011/05/12 12:24
|