Hello all. I am fairly new to C and am wanting to get my feet wet by recreating a popular game I used to play on my calculator. HickQuest.
I am coming to C from PHP and was just starting to get into OOP and using classes more and more often.
I am fearing that I may have to use C++ for this project of mine instead of C, which is what I want to use. Only C.
I am just learning to use structs (which seem much like classes to me) and am having a hard time figuring out how to link everything to gether much like you would a class.
Sadly, this is all I have come up with before having to post here.
#include <stdio.h>
#define deadLife 0
void Pause(void){
char *c;
printf("Press Enter to continue . . .\n");
while((c = getchar()) != '\n'){ }
free(c);
}
typedef struct {
char *name;
int minPower, maxPower;
int maxLife, currentLife;
char *currWeapon, *currShield;
} Enemies;
int main(void){
printf("Hello.\n");
Pause();
return 0;
}
Should I be looking into ObjC?
TIA.
A class (without all the bells and whistles of polymorphism and inheritance) is just a C-structure that has assoicated member functions. Then the class itself is merely just a collection of member data, same as a C-struct. In C++ the functions assoicated with a class are only accessable by calling them on a class instance, so if you were to make normal functions that operate on a structure you can get the same effect.
For example, in C++ a class may be defined as:
class square {
public:
square(int h, int w);
int area();