Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私は宿題をしなければなりませんが、C のパスを取ることができません。
int main(void) { char *path; path = getenv("PATH"); if(path) printf("The current path is: %s\n", path); return 0; }
このコードを実行すると、「セグメンテーション エラー (コア ダンプ)」が発生しました。私のOSはUbuntu 14.04 LTSです。
追加
#include <stdlib.h>
リストの一番上に移動して、試してみてください。getenv から char * ポインターへの int 戻りが想定され、コードがトリップする可能性があります。