I am attempting to get an input that can have varied types, float, int and a string are the three, I'm using sscanf to analyze the input from a buffer but for some reason I am getting memory access violations and I don't really know why.

Main program:

#include "assessGrade.h"

int main(void)
	char buffer[80] = {NULL};
	int tempAssign[5] = {NULL};
	double tempFinal = 0;
	char tempAlpha[4] = {NULL};
	double finalMark = 0;
	//double converterFloat[80] = {NULL};
	//char converterInt[80] = {NULL};
	printf("Please enter an alpha grade or condition, the final mark or the assignment marks in the format \"Mark1, Mark2, etc");
	fgets(buffer, 80, stdin);

	//converterFloat = atof(buffer);
	//converterInt = atoi(buffer);


	if (sscanf(buffer, "%lf", tempFinal) != 0)
		//finalMark = calculateMark(tempFinal);

	if (sscanf(buffer, "%s", tempAlpha) !=0)
		//finalMark = calculateMark(tempAlpha);

	if (sscanf(buffer, "%d %d %d %d %d", tempAssign[1], tempAssign[2], tempAssign[3], tempAssign[4], tempAssign[5]) != 0)
		//finalMark = calculateMark(tempAssign);

	printf("%s", tempAlpha);
	printf("%d", tempAssign);
	printf("%f", tempFinal);

	return 0;



#include <stdio.h>
#include <stdlib.h>

//double calculateMark(char letterGrade[4]);
//double calculateMark(double finalGrade);
//double calculateMark(int assignMark[5]);

The commented parts out are obviously there purposely, I don't have that part of the code functioning yet and/or have it disabled because I am isolating my input code. Anyone have any insight as to why I'm having issues?

This question has already been answered. Start a new discussion instead.