For parsing words separately from one another, my teacher told me to use strtok. I'll also need to be able to put all the information about each square on the map, the teacher is saying I should use struct. It's a big computer class and only a couple of us are doing programming, so he's always off helping someone else. I can't find any simple info or examples for those functions...
Here's what I have now:
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int x, y, z;
x=5;
y=5;
z=0;
printf("[%d,%d] You are standing on the north side of a lake. Your pants are floating in the water. [Points: %d]\n", x, y, z);
char buffer[50];
fgets(buffer, 50, stdin);
if (strcmp(buffer,"get pants\n") == 0)
{
z=z+5;
printf("[%d,%d] You put on the wet pants. They feel slimy. [Points: %d]\n", x, y, z);
}
else if (strcmp(buffer,"west\n") == 0)
{
printf("[%d,%d] Are you sure you want to walk around with no pants on? [Points: %d]\n", x, y, z);
}
else if (strcmp(buffer,"east\n") == 0)
{
printf("[%d,%d] Are you sure you want to walk around with no pants on? [Points: %d]\n", x, y, z);
}
else if (strcmp(buffer,"north\n") == 0)
{
printf("[%d,%d] Are you sure you want to walk around with no pants on? [Points: %d]\n", x, y, z);
}
else if (strcmp(buffer,"south\n") == 0)
{
printf("[%d,%d] Are you sure you want to walk around with no pants on? [Points: %d]\n", x, y, z);
}
else
{
printf("That is an unknown command.\n");
}
fgets(buffer, 50, stdin);
if (strcmp(buffer,"get pants\n") == 0)
{
z=z+5;
printf("[%d,%d] You put on the wet pants. They feel slimy. [Points: %d]\n", x, y, z);
}
sleep(2000);
}