"Advanced_C"라는 책을 읽고 "POINTERS.C"샘플 코드 컴파일을 시도했습니다.호환되지 않는 포인터 유형 경고에서 할당
나는 codeblocks에서 빌드하고 실행했으며 cc를 리눅스에서 시도했지만 "호환되지 않는 포인터 유형에서 할당"이라는 경고 메시지가 나타납니다.
#include <stdio.h>
#include<string.h>
int main(void);
int main()
{
int nCounter = 33;
int *pnCounter = (int *)NULL;
char szSaying[] =
{
"Firestone's Law of Forecasting: \n"
"Chicken Little only has to be right once.\n\n"
};
char *pszSaying = (char *)NULL;
printf(
"nCounter | pnCounter | *(pnCounter) | pszSaying | "
"szSaying[0] | szSaying[0-20]\n");
printf("%8d | %8p | %8d | %8p | %c | %20.20s\n",
nCounter,
pnCounter,
*(pnCounter),
pszSaying,
*(pszSaying),
szSaying);
printf("pnCounter = &nCounter; \n");
pnCounter = &nCounter;
printf("%8d | %8p | %8d | %8p | %c | %20.20s\n",
nCounter,
pnCounter,
*(pnCounter),
pszSaying,
*(pszSaying),
szSaying);
printf("pszSaying = szSaying; \n");
pszSaying = szSaying;
printf("%8d | %8p | %8d | %8p | %c | %20.20s\n",
nCounter,
pnCounter,
*(pnCounter),
pszSaying,
*(pszSaying),
szSaying);
printf("pszSaying = &szSaying; \n");
pszSaying = &szSaying;
printf("%8d | %8p | %8d | %8p | %c | %20.20s\n",
nCounter,
pnCounter,
*(pnCounter),
pszSaying,
*(pszSaying),
szSaying);
printf("pszSaying = &szSaying[0]; \n");
pszSaying = &szSaying[0];
printf("%8d | %8p | %8d | %8p | %c | %20.20s\n",
nCounter,
pnCounter,
*(pnCounter),
pszSaying,
*(pszSaying),
szSaying);
printf("*(pnCounter) = 1234; \n");
*(pnCounter) = 1234;
printf("%8d | %8p | %8d | %8p | %c | %20.20s\n",
nCounter,
pnCounter,
*(pnCounter),
pszSaying,
*(pszSaying),
szSaying);
return (0);
}
저는 C 프로그래밍을 처음 사용했습니다.
감사합니다!
__Where__ 경고가 표시됩니까? – tkausl
무엇이 당신의 질문입니까? –
'pszSaying = & szSaying;':'pszSaying'은'char *'이고'szSaying'은''char **' –