- 2
Please, make code, which will show us todays data in struct function at C programme.
https://code.sololearn.com/c3Mar6AbI6lh/?ref=app For example, we will write 23/4/2019 and it will show us that Today is 23 April 2019.
8 Réponses
+ 1
Are you allowed to use array? you can try this approach if you are allowed to use arrays
// add this array
const char* MONTHS[12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
// and for printing you do this
printf("Today is %d %s %d\n", tData.day, MONTHS[tData.month - 1], tData.year);
Alternatively, you can also use `switch` to solve this.
+ 1
Elvin,
Try to add the array line in your main function. And call `printf` in main function as I had shown in my previous response. It's that simple, I'm very sure you can do this.
Talk to me again after you make the update in your code, let me know how it goes, okay?
+ 1
I write your code like this, but there are some problems, can you look at this, and show me where is the problem
+ 1
Oh, ok i understand, thank you🙂
+ 1
You're welcome Elvin 👍
0
Can you just make or write the ready form of this code. )
0
Elvin,
First, 👍 for not giving up.
Now, about the code. I see you changed the specifier in your call to `scanf`. But it was not necessary, you can call `scanf` as you did before.
scanf("%d/%d/%d", &tData.day, &tData.month, &tData.year);
// Line 8
Just like this. Hopefully it works well by then : )