struct list{
char *Name;
};
void chekFC(struct list *newList){
char *fC = newList->Name;
printf("%s\n", &fC); //I can print it
if(fC[0] == '+') //Any error??
printf("Yes");
}
int main(){
struct list *newList = (struct list *)malloc(sizeof(struct list));
newList->Name = "+abc";
chekFC(newList);
}
나는이 프로그램을 실행할 수없는 이유는 무엇C 문자 포인터를 비교
void chekFC(struct list *newList){
char *fC = newList->Name;
printf("%s\n", &fC); //I can print it
if(fC[0] == '+') {} // Add {} nothing run in the if condition, than the program can run
printf("Yes");
}
을 다음 코드를 변경하는 경우는, 실행할 수 있습니까? 오류는 세그먼트 오류입니다 (코어 덤프 됨)
아마도'newList-> Name'을 초기화 한 적이 없을 것입니다 ... – Mysticial
이 코드 조각에서 잘못된 점을 말하는 것은 불가능합니다. 문제를 나타내는 가장 작은 완전한 프로그램을 게시하십시오. – Spire
전체 코드, 특히'newList-> Name '을 할당하는 비트를 표시합니다. –