Home c++ Error Expected Primary-Expression Before ')' Token

Error Expected Primary-Expression Before ‘)’ Token

Author

Date

Category

Program code:

# include & lt; iostream & gt;
#Include & lt; algorithm & gt;
#Include & lt; conio.h & gt;
#Include & lt; vector & gt;
Using Namespace STD;
Struct CH {
   int chislo;
   int ST_2;
   int ST_3;
   };
Vector & lt; CH & GT; ch_v;
INT MAIN () {
 int n, i, dv = 0, tr = 0;
 COUT & LT; & LT; "Skolko Budet Chisel?";
 CIN & GT; & GT; n;
 int a [n];
 COUT & LT; & LT; "VVedite Chisla";
 for (i = 0; i & lt; n; i ++)
  CIN & GT; & GT; A [I];
 SORT (A, A + N);
 ch_v.push_back (CH);
 For (i = 0; i & lt; n; i ++) {
  ch_v [i] .chislo = a [i];
  COUT & LT; & LT; ch_v [i] .chislo & lt; & lt; "";
  While (A [I]% 2 == 0) {
   a [i] / = 2;
   DV ++;
  }
  ch_v [i] .st_2 = dv;
  COUT & LT; & LT; ch_v [i] .st_2 & lt; & lt; "";
  DV = 0;
  While (A [i]% 3 == 0) {
   A [i] / = 3;
   TR ++;
  }
  ch_v [i] .st_3 = tr;
  COUT & LT; & LT; ch_v [i] .st_3 & lt; & lt; "";
  tr = 0;
 }
 getch ();
 Return (0);
}

ch_v.push_back (CH); here in this place gives the specified error. I can not understand that not so

z. Tomatoes please do not throw, I’m still new to


Answer 1, Authority 100%

You are trying to insert data type vector. Not the value of the structure, but the type.

Instead of ch_v.push_back (CH);

You need to write something like

ch dd;
dd.chislo = …; // Here you need to substitute the necessary numbers.
dd.st_2 = …;
dd.st_3 = ..;

ch_v.push_back (dd);

But the logic of this Push_back in this place eludes me. Therefore, I can not say what exactly needs to be inspired.

Code Of course you need to format well. This is not Python, there will be no returns here.

and it would be good to apply the condition itself.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions