Hello everyone,

I'm Jesse and new to the forum.
I'm also quite new to C programming and I have a problem when dereferencing a char* from strstr().

I am trying to program an rss bencode html translater for minix for an OS-assignment. The problem is not related, however. Every time I dereference the char* that strstr() produces I get the following error at runtime:

VM: pagefault: SIGSEGV 36686 bad addr 0x64 (dataseg); err 0x4 nopage read
PM: coredump signal 11 for 145 / rssParse
rssPars 36686 0x4a0b 0x3700 0x206e 0x212d 0x2277 0x100a
Memory fault (core dumped)


Also I'm not sure what to use for size and count arguments in fread.

Here is the code so far.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define WRITE_FILE 	"rss.html"
#define BEGIN_HTML 	"<html><head><title</title></head><body>"
#define END_HTML 	"</body></html>"

// global variables
FILE* wFile;
size_t wResult;
struct item* items;

void parse(char* content, size_t size, size_t count);
char* getTagValue(char* string, const char* tag);


struct item {
	char* title;
	char* description;
	char* author;
	char* link;
	char* guid;
	char* pubDate;
};

void parse(char* content, size_t size, size_t count) {
	printf("Buffer addr: %p; length: %d\n", content, strlen(content));
	void* wBuffer;
	size_t newSize, newCount;
	struct item inner;
	char* tag;

	printf("Size: %d", strlen(content));
	printf("Description: %s\n", getTagValue(content, "description"));

	
	wResult = fwrite((void*)content, size, count, wFile);

}

char* getTagValue(char* string, const char* tag) {
	char* ptr = strstr(string, tag);// causing invalid memory addresses
	printf("check: ptr: %s", *ptr);
		if(ptr != NULL) {
			return ""; // actual code omitted
		}
}

int main(int argc, char* argv[]) {
	// variables for reading
	FILE* rFile;
	void* buffer;
	size_t rSize, rCount, rResult;
	
	if(argc != 2) {
		printf("WARNING: Wrong arguments\n");
		return -1;	
	}
	rFile = fopen(argv[1], "rb");
	if(rFile == NULL) {
		printf("ERROR: File could not be openend\n");
		return -1;
	}
	// Open file for writing in parse()
	wFile = fopen(WRITE_FILE, "w");
	
	// Not sure what to use for rSize and rCount in fread()
	rSize = 100;
	rCount = 1;
	buffer = malloc(rSize*rCount);
	while(!feof(rFile)) {
		rResult = fread(buffer, rSize, rCount, rFile);
		parse((char*)buffer, rSize, rCount);
	}
	fclose(rFile);
	fclose(wFile);
	free(buffer);
	return 0;
}