I have just started to write this program and the problem is the output. I'm not sure if I'm setting the char array, because it looks like I'm not. The output is just numerous "=". Can you take a look at it? Here is the code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct problem {
	char answer[100];
	char question[1024];
	struct problem *next_prob;
};

// function prototypes
struct problem *getques(FILE *, struct problem *);
int getquestans(char question[], char ans[], FILE *fp);

int main(int argc, char *argv[])
{
	FILE *fp;
	struct problem *head_prob;	// head struct to pass to function
	head_prob = NULL;

	fp = fopen(argv[1], "r"); // open the file to read
	
	if (fp == NULL)
	{
		// file not found
		printf("File not found!\n");
		return 0;
	}

	else
		head_prob = getques(fp, head_prob);

	printf("question: %s\n", head_prob->question);

	return 0;
}

struct problem *getques(FILE *fp, struct problem *head_prob)
{
	int yesno;
	struct problem *temp;
	temp = malloc(sizeof(struct problem));
	head_prob = malloc(sizeof(struct problem));
	head_prob->next_prob = NULL;
	temp->next_prob = NULL;
printf("**while loop\n");
	while (yesno != EOF)
	{
		temp->next_prob = NULL;
		yesno = getquestans(head_prob->question, head_prob->answer, fp);
		printf("**after fgets\n");

		printf("**before next_prob\n");
		head_prob->next_prob = temp;
		printf("**head_prob->next_prob = temp\n");
		head_prob = head_prob->next_prob;
		printf("**successful next prob\n");
	}
	printf("**return successful\n");
	return head_prob;
}

int getquestans(char *question, char *answer, FILE *fp)
{
	char ch, q=0, a=0, i;

	while (ch != '\n')
	{
		if (ch == EOF)
			return EOF;

		ch = fgetc(fp);

		if (ch == ':')
		{
			i = 1;
			continue;
		}

		else if (i == 0)
		{
			question[q] = ch;
			q++;
		}

		else if (i == 1)
		{
			answer[a] = ch;
			a++;
		}
	}
	return 0;
}
Don't mind some of the printf calls. They are just there to pin-point the problem. But, I can't find it.

Thanks.

--Garfield