#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int polls(const char *user, int *vote);

int main() {
	polls("spence",0);
	return 0;
}

int polls(const char *user, int *vote) {
	char pathname[30];
	char polltemp[255];
	char ch;
	int i;
	int k;
	FILE *fh = 0;
	
	//setup pathname var for the users files
	strcpy(pathname,"./");
	strcat(pathname,user);
	strcat(pathname,"/polls/");
	strcat(pathname,"polls");
		
	if ( !(fh=fopen(pathname,"r")) ) {   //open the file and bitch if it can't be opened
		fprintf(stderr,"Cannot open input file.\n");
		return 2;
	}
	k = 0;
	while(ch != EOF) {
		i = 0;
		//printf("foo");
		while(polltemp[i] != ' ') { //cleanup time for polltemp
			polltemp[i] = ' ';
			i++;
		}
		i = 0;
		while((ch = fgetc(fh)) != '\n' && ch != EOF) {
			polltemp[i] = ch;
			i++;	
		}	
		printf("%s: ",polltemp);
		while((ch = fgetc(fh)) != '\n' && ch != EOF) {
			polltemp[i] = ch;
			i++;	
		}
		printf(" %s\n",polltemp);
		k++;
	}
	return 0;
}
