" &" isn't working

Problem description

I need to write the following program:

printf("enter value of a: "); scanf("%f", &a); 

It is giving following error when I debug it:

main.c:8:33: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |  printf("enter value of a: "); scanf("%f", &a);
      |  

Expected behavior

main.c:8:33: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |  printf("enter value of a: "); scanf("%f", &a);

Actual behavior

It should run the program and user allow to take an input

Steps to reproduce

Scanf should run it and allow user for an input

Browser

Chrome

OS

Windows 10

Device if mobile

N/A

Plan

Free tier

Welcome to Ask @anandigbt!

Please change the category of this topic to Code Help. You can do this by editing your post.

I can’t reproduce this, the below works fine in the C template:

// in `main`
float a;
printf("enter value of a: ");
scanf("%f", &a);

Note that this isn’t actually an error, this is a warning. It is being treated as an error because in Makefile, CFLAGS is overridden to include -Wno-everything. If you don’t want to treat warnings as an error, you can remove this.

1 Like