私は次のcコードを書いていますが、エラーが発生します:
#include<stdio.h>
#include<stdlib.h>
int main()
{
char *prot;
char addr[20];
FILE *fp;
int i = 0;
int tos,pld;
prot = (char *)malloc(sizeof(char *));
//addr = (char *)malloc(sizeof(char *));
printf("\n enter the protocol for test::");
scanf(" %s",prot);
printf("\n enter the addr::");
scanf(" %s",addr);
printf("\n enter the length of the payload::");
scanf(" %d",pld);
printf("\n enter the tos :: ");
scanf(" %d",tos);
値の入力中に次のエラーが発生します。セグメンテーションフォールトが発生しています。このセグメントフォールトが発生する理由を誰かに教えてもらえますか。
enter the protocol for test::we
enter the addr::qw
enter the length of the payload::12
Segmentation fault