PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, June 26, 2022

[FIXED] Why does my code say that it has an incomplete type even after I tried declaring it?

 June 26, 2022     c++, compiler-errors, declaration, incomplete-type, struct     No comments   

Issue

I am writing a program that displays a number of students test scores in the form of a table and then calculates and displays the average. Upon running the code, I get the following errors(also pictured below): variable has incomplete type 'struct students' struct students st[50]; ^ note: forward declaration of 'students' struct students st[50];

I have declared students and have tried declaring st and I am just not sure what the problem is. Below is a typed version and a screenshot of my code:

#include <iostream>
using namespace std;
int Main()
{
  int students;

   struct students st[50]; 
   return 0;
}

Code errors Picture of typed code


Solution

You have to define it first. You can also use this style.

struct student{
    ...
};

int main{
    student* st[50];
    for(int i=0; i<50;i++)
        st[i]=new student;
    return 0;
}


Answered By - emtsdmr
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing