I am trying to make a program that shows what groceries the user ordered. It will write in another file (when it’s complete) the data, and show the average of each food group. It goes like this:
#include<stdio.h>
int main()
{
int beverage[3][20] = {
"Soda"
"Water"
"Coffee"
}; /* Here is 9 */
int produce[3][20] = {
"Apple"
"Carrot"
"Banana"
}; /* Here is 14 */
int dairy[3][20] = {
"Milk"
"Yogurt"
"Cheese"
}; /* Here is 19 */
int dessert[3][20] = {
"Ice Cream"
"Cake"
"Chocolate"
}; /* Here is 24 */
int meat[3][20] = {
"Chicken"
"Seafood"
"Beef"
}; /* Here is 29 */
int grain[3][20] = {
"Bread"
"Muffin"
"Cereal"
}; /* Here is 34 */
printf("Beverages: %p\n ", beverage[1]);
printf("Produce: %p\n ", produce[2]);
printf("Dairy: %p\n ", dairy[0]);
printf("Candy: %p\n ", dessert[0]);
printf("Meat: %p\n ", meat[2]);
printf("Grain: %p\n ", grain[1]);
return 0;
}
It shows the error message, “wide character array initialized from non-wide string,” in lines 9, 14, 19, 24, 29, and 34. So what does the error message mean to my code? How do I change it and where?
If what you want are lists of strings (which I assume is what you want). You should be using
charinstead ofint: