Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › can some one ex-plane how typedef works under C? [Solved]
New Posts  All Forums:Forum Nav:

can some one ex-plane how typedef works under C? [Solved] - Page 2

post #11 of 25
Thread Starter 
ok so now i understand what it does now i have to study it smile.gif thanks....
My computer
(18 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core 2 Duo E6600 DG965SS powercolor 6670   
RAMHard DriveOptical DriveCooling
G.Skill Seagate  DVD WRITER heat sink + fan 
OSOSOSMonitor
Windows 7 Windows XP Linux Ubuntu FLATRON L1740B 
KeyboardPowerCaseMouse
Microsoft Basic 500 WATT PSU TOWER Microsoft Basic 
AudioOther
IDT intergrated AUDIO 5.1 speakers 
  hide details  
Reply
My computer
(18 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core 2 Duo E6600 DG965SS powercolor 6670   
RAMHard DriveOptical DriveCooling
G.Skill Seagate  DVD WRITER heat sink + fan 
OSOSOSMonitor
Windows 7 Windows XP Linux Ubuntu FLATRON L1740B 
KeyboardPowerCaseMouse
Microsoft Basic 500 WATT PSU TOWER Microsoft Basic 
AudioOther
IDT intergrated AUDIO 5.1 speakers 
  hide details  
Reply
post #12 of 25
Quote:
Originally Posted by thecoredude98 View Post

ok so now i understand what it does now i have to study it smile.gif thanks....

No worries wink.gif
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
post #13 of 25
Thread Starter 
okay i did some study this is what i coded up

Code:
#include <stdio.h>
#include <conio.h>


typedef struct calculator{
  
  int num1;
  int num2;
  char operation;     
       
};

  int main(){

  struct calculator fun;

  fun.num1;
  fun.num2;
  fun.operation;


printf("please input something to calculate");

scanf("%d%c%d",&fun.num1,&fun.operation,&fun.num2);

if(fun.operation == '+') printf("%d",fun.num1+fun.num2);

else if(fun.operation == '-') printf("%d",fun.num1-fun.num2);

else if(fun.operation == '/') printf("%d",fun.num1/fun.num2);

else if(fun.operation == '*') printf("%d",fun.num1*fun.num2);
 
else{

    printf("please input somthing vaild");   
    getchar();
}   
    getchar();
    getchar();
}

Edited by thecoredude98 - 2/14/12 at 4:58am
My computer
(18 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core 2 Duo E6600 DG965SS powercolor 6670   
RAMHard DriveOptical DriveCooling
G.Skill Seagate  DVD WRITER heat sink + fan 
OSOSOSMonitor
Windows 7 Windows XP Linux Ubuntu FLATRON L1740B 
KeyboardPowerCaseMouse
Microsoft Basic 500 WATT PSU TOWER Microsoft Basic 
AudioOther
IDT intergrated AUDIO 5.1 speakers 
  hide details  
Reply
My computer
(18 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core 2 Duo E6600 DG965SS powercolor 6670   
RAMHard DriveOptical DriveCooling
G.Skill Seagate  DVD WRITER heat sink + fan 
OSOSOSMonitor
Windows 7 Windows XP Linux Ubuntu FLATRON L1740B 
KeyboardPowerCaseMouse
Microsoft Basic 500 WATT PSU TOWER Microsoft Basic 
AudioOther
IDT intergrated AUDIO 5.1 speakers 
  hide details  
Reply
post #14 of 25
Quote:
Originally Posted by thecoredude98 View Post

okay i did some study this is what i coded up
Code:
#include <stdio.h>
#include <conio.h>
typedef struct calculator{
  
  int num1;
  int num2;
  char operation;     
       
};
  int main(){
  struct calculator fun;
  fun.num1;
  fun.num2;
  fun.operation;
printf("please input something to calculate");
scanf("%d%c%d",&fun.num1,&fun.operation,&fun.num2);
if(fun.operation == '+') printf("%d",fun.num1+fun.num2);
else if(fun.operation == '-') printf("%d",fun.num1-fun.num2);
else if(fun.operation == '/') printf("%d",fun.num1/fun.num2);
else if(fun.operation == '*') printf("%d",fun.num1*fun.num2);
 
else{
    printf("please input somthing vaild");   
    getchar();
}   
    getchar();
    getchar();
}

typedef'ing a struct without a qualifier doesn't do anything....,what did you typedef it as?

You could have done this and avoided the need to use struct every time you declare a variable of your struct though: (this is required in C, however isn't required in C++. and you'll see how to get that C++ behavior in C below)
Code:
typedef struct _calculator{
  
  int num1;
  int num2;
  char operation;     
       
} calculator;

Then use as following:
Code:
calculator fun;

Notice how I did not have to write "struct calculator fun"

thumb.gif
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
post #15 of 25
Thread Starter 
Quote:
Originally Posted by tompsonn View Post

typedef'ing a struct without a qualifier doesn't do anything....,what did you typedef it as?
You could have done this and avoided the need to use struct every time you declare a variable of your struct though:
Code:
typedef struct _calculator{
  
  int num1;
  int num2;
  char operation;     
       
} calculator;
Then use as following:
Code:
calculator fun;
Notice how I did not have to write "struct calculator fun"
thumb.gif

yes i will look into that even more smile.gif
My computer
(18 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core 2 Duo E6600 DG965SS powercolor 6670   
RAMHard DriveOptical DriveCooling
G.Skill Seagate  DVD WRITER heat sink + fan 
OSOSOSMonitor
Windows 7 Windows XP Linux Ubuntu FLATRON L1740B 
KeyboardPowerCaseMouse
Microsoft Basic 500 WATT PSU TOWER Microsoft Basic 
AudioOther
IDT intergrated AUDIO 5.1 speakers 
  hide details  
Reply
My computer
(18 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core 2 Duo E6600 DG965SS powercolor 6670   
RAMHard DriveOptical DriveCooling
G.Skill Seagate  DVD WRITER heat sink + fan 
OSOSOSMonitor
Windows 7 Windows XP Linux Ubuntu FLATRON L1740B 
KeyboardPowerCaseMouse
Microsoft Basic 500 WATT PSU TOWER Microsoft Basic 
AudioOther
IDT intergrated AUDIO 5.1 speakers 
  hide details  
Reply
post #16 of 25
Yep, this is used all through the Windows API to unify development in C or C++, for example the RECT structure is defined like so:
Code:
typedef struct tagRECT
{
    LONG    left;
    LONG    top;
    LONG    right;
    LONG    bottom;
} RECT, *PRECT, NEAR *NPRECT, FAR *LPRECT;
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
post #17 of 25
Thread Starter 
Code:
#include <stdio.h>
#include <conio.h>


typedef struct _calculator{
  
  int num1;
  int num2;
  char operation;     
       
}calculator;

int main(){

calculator fun;

fun.num1;
fun.num2;
fun.operation;


printf("please input something to calculate\n");

scanf("%d%c%d",&fun.num1,&fun.operation,&fun.num2);

if(fun.operation == '+') printf("%d",fun.num1+fun.num2);

else if(fun.operation == '-') printf("%d",fun.num1-fun.num2);

else if(fun.operation == '/') printf("%d",fun.num1/fun.num2);

else if(fun.operation == '*') printf("%d",fun.num1*fun.num2);
 
else{
    printf("please input somthing vaild\n");   
    getchar();
}   
    getchar();
    getchar();
}

now it makes absalote sence thanks man smile.gif
My computer
(18 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core 2 Duo E6600 DG965SS powercolor 6670   
RAMHard DriveOptical DriveCooling
G.Skill Seagate  DVD WRITER heat sink + fan 
OSOSOSMonitor
Windows 7 Windows XP Linux Ubuntu FLATRON L1740B 
KeyboardPowerCaseMouse
Microsoft Basic 500 WATT PSU TOWER Microsoft Basic 
AudioOther
IDT intergrated AUDIO 5.1 speakers 
  hide details  
Reply
My computer
(18 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core 2 Duo E6600 DG965SS powercolor 6670   
RAMHard DriveOptical DriveCooling
G.Skill Seagate  DVD WRITER heat sink + fan 
OSOSOSMonitor
Windows 7 Windows XP Linux Ubuntu FLATRON L1740B 
KeyboardPowerCaseMouse
Microsoft Basic 500 WATT PSU TOWER Microsoft Basic 
AudioOther
IDT intergrated AUDIO 5.1 speakers 
  hide details  
Reply
post #18 of 25
Quote:
Originally Posted by thecoredude98 View Post

Code:
#include <stdio.h>
#include <conio.h>
typedef struct _calculator{
  
  int num1;
  int num2;
  char operation;     
       
}calculator;
int main(){
calculator fun;
fun.num1;
fun.num2;
fun.operation;
printf("please input something to calculate\n");
scanf("%d%c%d",&fun.num1,&fun.operation,&fun.num2);
if(fun.operation == '+') printf("%d",fun.num1+fun.num2);
else if(fun.operation == '-') printf("%d",fun.num1-fun.num2);
else if(fun.operation == '/') printf("%d",fun.num1/fun.num2);
else if(fun.operation == '*') printf("%d",fun.num1*fun.num2);
 
else{
    printf("please input somthing vaild\n");   
    getchar();
}   
    getchar();
    getchar();
}
now it makes absalote sence thanks man smile.gif

Also, you don't need to explicitly "declare" the members of your structure smile.gif
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
post #19 of 25
Thread Starter 
Quote:
Originally Posted by tompsonn View Post

Also, you don't need to explicitly "declare" the members of your structure smile.gif
Code:

#include <stdio.h>
#include <conio.h>


  typedef struct _calculator{
  
  int num1;
  int num2;
  char operation;     
       
}calculator;

int main(){

calculator fun;

printf("please input something to calculate\n");

scanf("%d%c%d",&fun.num1,&fun.operation,&fun.num2);

if(fun.operation == '+') printf("%d",fun.num1+fun.num2);

else if(fun.operation == '-') printf("%d",fun.num1-fun.num2);

else if(fun.operation == '/') printf("%d",fun.num1/fun.num2);

else if(fun.operation == '*') printf("%d",fun.num1*fun.num2);
 
else{

    printf("please input somthing vaild\n");   
    getchar();
}   
    getchar();
    getchar();
}




i see it still works the same
My computer
(18 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core 2 Duo E6600 DG965SS powercolor 6670   
RAMHard DriveOptical DriveCooling
G.Skill Seagate  DVD WRITER heat sink + fan 
OSOSOSMonitor
Windows 7 Windows XP Linux Ubuntu FLATRON L1740B 
KeyboardPowerCaseMouse
Microsoft Basic 500 WATT PSU TOWER Microsoft Basic 
AudioOther
IDT intergrated AUDIO 5.1 speakers 
  hide details  
Reply
My computer
(18 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core 2 Duo E6600 DG965SS powercolor 6670   
RAMHard DriveOptical DriveCooling
G.Skill Seagate  DVD WRITER heat sink + fan 
OSOSOSMonitor
Windows 7 Windows XP Linux Ubuntu FLATRON L1740B 
KeyboardPowerCaseMouse
Microsoft Basic 500 WATT PSU TOWER Microsoft Basic 
AudioOther
IDT intergrated AUDIO 5.1 speakers 
  hide details  
Reply
post #20 of 25
Quote:
Originally Posted by thecoredude98 View Post

i see it still works the same

Indeed wink.gif
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › can some one ex-plane how typedef works under C? [Solved]