Új hozzászólás Aktív témák
-
Dirty_Pio
csendes tag
válasz
Dirty_Pio
#837
üzenetére
Kozbe reajottem egy-ket hibara szoval az uj kod mar igy nez ki
#include <stdio.h>
#include <stdlib.h>
enum star_type{ MA,BIN,VAR};
typedef struct {
char name[51];
enum star_type tp;
union star{
struct mai{
unsigned char type:2;
unsigned char age:2;
char color[11];
}m;
struct bin{
float r1;
float r2;
unsigned char t1:2;
unsigned char t2:2;
}b;
struct var{
float lowlmn;
float highlmn;
float period;
}v;
}u;
}stars;
int main(void){
enum star_type a;
int n,i;
stars *x=(stars *)malloc(sizeof(stars)*10);
printf("which type of definition would you like to use for the stars?\n");
scanf("%d",&a);
printf("How many stars?(max 10)\n");
scanf("%d",&n);
for (i=0;i<n;i++){
switch (a){
MA:
scanf("%50s",x.name);
x.tp=a;
scanf("%c %c %s",x.u.m.type, x.u.m.age, x.u.m.color);
break;
BIN:
scanf("%50s",x.name);
x.tp=a;
scanf("%f %f %c %c",x.u.b.r1,x.u.b.r2,x.u.b.t1,x.u.b.t2);
break;
VAR:
scanf("%50s",x.name);
x.tp=a;
scanf("%f %f %f",x.u.v.lowlmn,x.u.v.highlmn,x.u.v.period);
break;
default break;
};
for (i=0;i<n;i++)
switch (x.tp){
MA:
printf("%c %c %s\n",x.u.m.type, x.u.m.age, x.u.m.color);
break;
BIN:
printf("%f %f %c %c\n",x.u.b.r1,x.u.b.r2,x.u.b.t1,x.u.b.t2);
break;
VAR:
printff("%f %f %f\n",x.u.v.lowlmn,x.u.v.highlmn,x.u.v.period);
break;
default break;
};
system("pause");
return(0);
}de meg mindig nem megy

Új hozzászólás Aktív témák
● olvasd el a téma összefoglalót!
● ha kódot szúrsz be, használd a PROGRAMKÓD formázási funkciót!
- AMD Radeon RX 7600 8GB OC HIBÁTLAN!!
- Hibátlan 2+ Év Garancia! GIGABYTE GeForce RTX 4060 EAGLE OC 8GB
- AZONNAL KÉSZLETRŐL! AMD Ryzen 7 9800X3D 64GB 6000MHz RAM 2TB Gen4 SSD RTX 5090 32GB GDDR7 1200W
- AZONNAL KÉSZLETRŐL! Intel Core i5 14600K 64GB 6000MHz RAM 2TB Gen4 SSD RTX 5060 8GB FSP 750W
- AZONNAL KÉSZLETRŐL! Intel Core i5 14600K 32GB 6000MHz RAM 2TB Gen4 SSD RTX 5060 8GB FSP 750W
- Xbox Game Pass Ultimate előfizetések kedvező áron
- GYÖNYÖRŰ iPhone 12 mini 128GB Blue-1 ÉV GARANCIA - Kártyafüggetlen, MS3415 94% Akkumulátor
- Asus PN50 mini pc /Ryzen 5 4500U(6 mag)/8GB/250GB/WIN11 PRO/
- 164 - Lenovo Legion Pro 7 (16IRX9H) - Intel Core i9-14900HX, RTX 4090
- TomTom Go 5200 with Wi-Fi navigáció / 12 hó jótállás
Állásajánlatok
Cég: Laptopszaki Kft.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest


