current position:Home>Student information management system score summation

Student information management system score summation

2022-02-03 01:52:04 CSDN Q & A

The phenomenon and background of the problem

Defines the structure

typedef struct Contacts{    char id[10]; // Student number     char name[10];  // full name     char sex[10];  // Gender     char class_number[10];  // class     char class_name1[30];  // subject 1    char class_name2[30];  // subject 2    char class_name3[30];  // subject 3    char score[30];    // Total score     char score1[30];  // achievement 1    char score2[30];  // achievement 2    char score3[30];  // achievement 3}Student;

Using linked list to store , When my total score = achievement 1+2+3 Times wrong , Change it to int Other places report errors .

 void SingleOut(Student e){    e.score=e.score1+e.score2+e.score3;    cout<<" Student number 、 full name 、 Gender 、 class 、 subject 1、 achievement 、 subject 2、 achievement 、 subject 3、 achievement :\n";    cout<<setiosflags(ios_base::left)<<" "<<        <<" "<<<<" "<<<<" "<<e.class_number        <<" "<<e.class_name1<<" "<<e.score1        <<" "<<e.class_name2<<" "<<e.score2        <<" "<<e.class_name3<<" "<<e.score3        <<resetiosflags(ios_base::left)<<endl;    cout<<" The total score of the students is :"<<e.score;}
Operation results and error reporting contents

|254|error: invalid operands of types 'char [30]' and 'char [30]' to binary 'operator+'|

My solution ideas and tried methods

The reason for searching online is char Types cannot be added , take score-0 Error is still reported after the method conversion |254|error: invalid operands of types 'char*' and 'char*' to binary 'operator+'|

What I want to achieve

Just sum up the results , Why do you torture people so much

Refer to the answer 1:

hold score Change the type of int No arrays

Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.

Random recommended