Issue 139378
Summary Have to use int *ptr instead of int.
Labels new issue
Assignees
Reporter badlialrashidfourthprofile
    I was compiling the program if-else program, it got generate an error. The solution was to create an pointer "int *ptr", anybody got similar issue ?

~/ $ cat if-else-err.c
/* C if-else example without pointers*/
#include <stdio.h>

int main(void) {
  int num1, num2;
  printf("Enter the 1st number: ");
  scanf("%d",&num1);
 printf("Enter the 2nd number: ");
  scanf("%d",&num2);
  if (num1 > num2 ) {
    printf("%d is biggest\n",&num1);
    num2 = num1;
  } else {
      printf("%d is biggest\n",&num2);
    num1 = num2;
  }
  return 0;
}
~/diveintosystems $ clang if-else-err.c
if-else-err.c:11:30: warning: format specifies type 'int' but the argument has type 'int *' [-Wformat]
 11 |     printf("%d is biggest\n",&num1);
      |             ~~ ^~~~~
if-else-err.c:14:32: warning: format specifies type 'int' but the argument has type 'int *' [-Wformat]
   14 |       printf("%d is biggest\n",&num2);
      |               ~~               ^~~~~
2 warnings generated.

~/ $ ./a.out
Enter the 1st number: 11
Enter the 2nd number: 22
-236698668 is biggest

~/ $ clang --version
clang version 20.1.4
Target: aarch64-unknown-linux-android24
Thread model: posix
InstalledDir: /data/data/com.termux/files/usr/bin
~/$

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to