これを実行すると、partName char 配列がガベージ char を出力します。理由はありますか?ありがとう!
typedef struct {
char partName[30];
int partNumber;
float price;
int stock;
int reorder;
} inventory;
struct address{
char streetAddress[25];
char city[20];
char state[3];
char zipCode[6];
};
void GetData(){
inventory order;
address orderAddress;
printf("Enter the part number (Database Includes orders 0001 - 0005): ");
scanf("%d", &order.partNumber);
if(order.partNumber == 0001){
order.partName == "Pokeball";
order.price == 200;
order.stock == 8263;
order.reorder == 888273;
orderAddress.streetAddress == "21 Oak St.";
orderAddress.city == "Kanto Town";
orderAddress.state == "IA";
orderAddress.zipCode == "28832";
printf("Part was: %s ", order.partName);
//printf("Order was sent to: \n %s\n %s\n %s\n %s\n", orderAddress.streetAddress, orderAddress.city, orderAddress.state, orderAddress.zipCode);
}
ランダムな文字が出力されていますが、どこかで単純なエラーであると確信しています。
みんなありがとう!