重複の可能性:
セグメンテーション違反-C
#include<stdio.h>
#include<string.h>
int main()
{
char *p;
printf("enter some thing:");
gets(p);
printf("you have typed:%s\n",p);
}
このプログラムが機能しないのはなぜですか?ポインタを文字列として使用できません。
出力は次のとおりです。
enter some thing:raihan
Segmentation fault (core dumped)
charポインタを使用するたびにこのエラーが発生します。どうすればこの問題を解決できますか?Linuxmint13KDEでコードブロックを使用しています。