I am trying to use swaps function and to initiate steps for a bubble sort. In the line 17 I tried to write `printf("%d", &nombre);`. and `printf("%d", nombre);` which respectively leed to the following warning, pasted after the snippet.
I cannot understand how to write the argument in the printf function. Can someone help me?
`bu.c:17:18: warning: format
specifies type 'int' but the
argument has type 'int *'
[-Wformat]
printf("%d", nombre);
~~ ^~~~~~
1 warning generated.
$ nano bu.c
$ clang bu.c -o bu
bu.c:17:18: warning: format
specifies type 'int' but the
argument has type 'int
(*)[card]' [-Wformat]
printf("%d", &nombre);
~~ ^~~~~~~
1 warning generated.`
I cannot understand how to write the argument in the printf function. Can someone help me?
Code:
#include <stdio.h>
2 void swaps(int *a, int *b);
3
4 int main()
5
6 {
7 int card, i, j;
8
9 printf("combien?\n");
10 scanf("%d", &card);
11 int nombre[card];
12 for (int i=0; i< card; i++)
13 {
14
15 printf("inscrivez un nombre.>
16 scanf("%d", &nombre[i]);}
17 printf("%d", &nombre);
18 int fois = card/2;
19 while(fois <=0)
20 {
21 for(int i = 0; i < card-1; i++)
22 {
23 swaps(&nombre[i], &nombre[i+1]);
24 }
25 fois--;
26 }
27
28 for(int i = 0; i< sizeof(nombre)>
29 {
30 printf("%d", nombre[i]);
31 }
32 return 0;
33 }
34
35 void swaps(int *a, int *b)
36 {
37 int temp;
38 if (*a > *b)
39 {
40 temp = *a;
41 *a = *b;
42 *b = temp;
43 }
44
45 }
`bu.c:17:18: warning: format
specifies type 'int' but the
argument has type 'int *'
[-Wformat]
printf("%d", nombre);
~~ ^~~~~~
1 warning generated.
$ nano bu.c
$ clang bu.c -o bu
bu.c:17:18: warning: format
specifies type 'int' but the
argument has type 'int
(*)[card]' [-Wformat]
printf("%d", &nombre);
~~ ^~~~~~~
1 warning generated.`
Comment