I am simulating a client/server interaction according to Beej's Guide to Network Programming. At the beginning of my server.c
file I am defining a port number with:
#define PORT "21124"
However, I will be creating several servers from this file and I would like to change this constant based on some if-else logic. Is there a functionality in C to easily accomplish this such as:
if (serverNumber == 1) {
#define PORT "21124"
}
else if (serverNumber == 2) {
#define PORT "12412"
}
else {
#define PORT "12334"
}
This may be a duplicate, but I didn't see it in the search. I'm a C
noob.
Aucun commentaire:
Enregistrer un commentaire