documentation from Microsoftのscanfに(const char *)があり、this questionの答えがあれば、(char **)のプロモーション(const char **)に同じことをすると、何が起こっているのでしょうか?これは(char *)から(const char *)へのプロモーションをなぜ許可しますか?
基本的に、これはなぜコンパイルされますか?
#include <stdio.h>
int main(int argc, char **argv)
{
char szArray[50];
int i = 0;
strcpy(szArray,"10");
/* the following code is upcasting the (char *) to (const char *) */
sscanf(szArray,"%d",&i);
return 0;
}
これはなぜコンパイルされませんか?
#include <stdio.h>
void processargs(const char **p)
{
}
int main(int argc, char **argv)
{
processargs(argv);
return 0;
}
どちらもポインタと同じことをしているようです!
あなたは1つのことを理解していません:もしT - > Uが働くなら、それはT * - > U *が意味するものではありません。単純なもの:double a = 4;/* int - > double */int p;ダブル* dp =&p;/* int * - > double * ?? */ –
私はここでタイプを変更していません...両方のセットはポインタです。 – ojblass
これ以外のものを閉じてください。 – ojblass