Jump to content

Incomplete type not allowed

Forenman
Go to solution Solved by WereCatf,
18 minutes ago, Forenman said:

I keep getting incomplete type error for "newexamresults", does anyone have any idea how to rectify this?

I see several mistakes, but this one's easy to fix: check your capital-letters.

#include <stdio.h>

struct examResults
{
	char title[20];
	unsigned int score[20];
};


myExam;


int main() {
	strcpy(myExam.title, "ClassA");
	myExam.score[1] = 20;
	myExam.score[17] = 69;

	struct examresults newexamresults[15];
	strcpy(newexamresults[5].title, "ClassB");
	strcpy(newexamresults[7].title, "ClassC");
	newexamresults[6].score[9] = 5;
	newexamresults[6].score[18] = 10;
	newexamresults[12].score[9] = 50;
	newexamresults[12].score[18] = 100;

	printf("%s\n", myExam.title);
	printf("%d\n", myExam.score[1]);
	printf("%d\n\n", myExam.score[17]);

	printf("%s\n", newexamresults[5].title);
	printf("%d\n", newexamresults[6].score[9]);
	printf("%d\n\n", newexamresults[6].score[18]);

	printf("%s\n", newexamresults[7].title);
	printf("%d\n", newexamresults[12].score[9]);
	printf("%d\n", newexamresults[12].score[18]);
}

I keep getting incomplete type error for "newexamresults", does anyone have any idea how to rectify this?

Link to comment
Share on other sites

Link to post
Share on other sites

18 minutes ago, Forenman said:

I keep getting incomplete type error for "newexamresults", does anyone have any idea how to rectify this?

I see several mistakes, but this one's easy to fix: check your capital-letters.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, WereCatf said:

I see several mistakes, but this one's easy to fix: check your capital-letters.

any hint on the other mistakes XD

 

Link to comment
Share on other sites

Link to post
Share on other sites

16 minutes ago, Forenman said:

any hint on the other mistakes XD

 

What is the type of the variable myExam? Which header file might contain the definition of strcpy()?

 

What IDE are you using? You should be receiving these hints in the form of warnings and errors even before attempting to compile if your tools are set up properly.

Link to comment
Share on other sites

Link to post
Share on other sites

43 minutes ago, Forenman said:

any hint on the other mistakes XD

You just have the word "myExam" there on a single line, without actually defining what it is.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×