KarenAUA / Individual_Project

0 stars 0 forks source link

Program does not work: Segmentation fault #1

Open narinehovhannisyan opened 2 years ago

narinehovhannisyan commented 2 years ago

There is warning reported during compilation:

$ gcc crc.c 
crc.c: In function ‘main’:
crc.c:35:10: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘unsigned char (*)[32]’ [-Wformat=]
   35 |  scanf("%s", &data);
      |         ~^   ~~~~~
      |          |   |
      |          |   unsigned char (*)[32]
      |          char *

The application fails:

$ ./a.out 
Enter the data 
0
Your data is: "0"
Segmentation fault (core dumped)
KarenAUA commented 2 years ago

Ms. Narine, instead of “%s” I wrote “%u” for unsigned char *. I think I fixed the problem. Thank You

On Saturday, May 21, 2022, Narine Hovhannisyan @.***> wrote:

There is warning reported during compilation:

$ gcc crc.c

crc.c: In function ‘main’:

crc.c:35:10: warning: format ‘%s’ expects argument of type ‘char ’, but argument 2 has type ‘unsigned char ()[32]’ [-Wformat=]

35 | scanf("%s", &data);

  |         ~^   ~~~~~

  |          |   |

  |          |   unsigned char (*)[32]

  |          char *

The application fails:

$ ./a.out

Enter the data

0

Your data is: "0"

Segmentation fault (core dumped)

— Reply to this email directly, view it on GitHub https://github.com/KarenAUA/Individual_Project/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXNZFR7NN4A6KYRFHHGUYS3VLBFM3ANCNFSM5WRESTKA . You are receiving this because you are subscribed to this thread.Message ID: @.***>