#include <stdio.h>
#include <string.h>
int main()
{
char arr[3][128]={"chk","help","ext"};
char in[128];
int i=0;
do
{
printf(">Type a command and press return.\n");
printf(">> ");
scanf("%s",in);
while( (i++ < 3) && (cm!=0 ) ) cm=strcmp(arr[1], in)!=0)
}
while(cm!=0);
printf("%d\n", cm);
return 0;
}
Also, scanf is really insecure. No input lenght control.
About checking a webpage, look for sockets. Something like (not finished, more than probably not working, on the fly):
int isOnline(char *web, int port)
{
int sock=socket(AF_INET, SOCK_STREAM, 0);
struct sockaddr_in addr;
struct hostent *host;
memset(&addr, 0, sizeof(struct sockaddr_in));
addr.sin_family=AF_INET;
addr.sin_port=htons(port);
addr.sin_addr = *((struct in_addr *) host->h_addr);
if(connect(sock, (struct sockaddr *)&addr, sizeof(struct sockaddr)) return 1;
else return 0;
}