My code that adds coordinates to an array does not work | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

My code that adds coordinates to an array does not work

My code does everything but what i want it to do #include <stdio.h> struct punto{int x; int y;}; typedef struct punto punto; int main(){ punto array[128]={}; int i=0; while(i<3){ printf("inserisci la x \n"); scanf("%d\n",&array[i].x); printf("inserisci la y \n"); scanf("%d\n",&array[i].y); i++;} }

15th May 2020, 3:28 PM
Guido Parlatore
Guido Parlatore - avatar
1 Answer
0
On which basis, you are saying, it is not working..? It is working for me, but you are not printing back results... Edit: #include <stdio.h> struct punto{int x; int y;}; typedef struct punto punto; int main(){ punto array[10]={}; int i=0; while(i<3){ printf("inserisci la x \n"); scanf("%d\n",&array[i].x); printf("inserisci la y \n"); scanf("%d\n",&array[i].y); i++;} i=0; while(i<3){ printf("%d\n",array[i].x); printf("%d\n",array[i].y); i++; } }
15th May 2020, 3:48 PM
Jayakrishna 🇮🇳