• Register
1 vote

Problem :

I am trying to enter numbers for my array br_el[6], and also I want it to show me for what object I am entering my number! So when I want to compile it gives me the below error:

"[Error] cannot pass objects of non-trivially-copyable type 'std::string {aka class std::basic_string}' through '...'"

 I have already tried to declare the string qr_naziv[6]; but my string didn't even bold so it didn't work for me, so looking for the solution on my error ?

6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I had also faced the similar issue in the recent past. I did lot of research on it and found the solution on it. This is the very common problem with the people getting started.

I must tell you that C functions are not acquainted with the C++ structures. You should do as the below:

for(j = 0; j < 6;j++) {
    printf("Input your number for %s =", qr_naziv[j].c_str());
    scanf("%d", &br_el[j]);


Please notice the call to your method c_str() on a each std::string qr_naziv[j], which returns the const char * to the null-terminated character array with the data equivalent to those stored in a string -- a C-like string.

If you follow the solution then your issue will be resolved.

9 7 4
38,600 points

Related questions

0 votes
1 answer 35 views
I am continiously getting this error array to string conversion error in PHP. How can i solve it?
asked Oct 4, 2020 Daniel Anderson 4k points
0 votes
1 answer 17 views
Problem: have a dataframe (df) that looks like: date A 2001-01-02 1.0022 2001-01-03 1.1033 2001-01-04 1.1496 2001-01-05 1.1033 2015-03-30 126.3700 2015-03-31 124.4300 2015-04-01 124.2500 2015-04-02 124.8900 For the entire time-series I'm trying to divide today's value by yesterdays and log the result using the following: df["B"] = math.log(df["A"] / df["A"].shift(1))
asked Jan 10 Mashhoodch 5.6k points
1 vote
1 answer 27 views
Problem: Hello all, I am struggling to solve a problem for the last thirty minutes using the c++ programing language. I was thinking of writing a program that will read the defined string and iterate through it and print all the words separately. Suppose I initialize a string with ... it very much How do you it or suggest me an easy way to do that. I look forward. Thanks for your kind assistance.
asked Jun 15, 2020 adamSw 11.3k points
0 votes
1 answer 18 views
I have a class called Pokemon, where I put 2 constructors, the first is for initialization and the other receives the name of a pokemon and completes it class Pokemon { private: string type; string advantage1; string advantage2; string resistance1; string resistance2; string ... const char [8]' to non-scalar type 'Pokemon' requested error: conversion from 'const char [9]' to non-scalar ty
asked Aug 14, 2020 game 4.6k points
0 votes
1 answer 10 views
My program consists of a menu that has: To register. Unsubscribe. Modify. To show. Leave. And the Person class with its constructors and methods. The Person class is something like this: Class Persona { private: char * dni; char * fullname; int age; public: Person (char ... is entered in the array but it doesn't work either. I hope you have understood me more or less and thank you very much!
asked Aug 17, 2020 game 4.6k points
0 votes
1 answer 75 views
Problem: I have been working on classes in C++ for about a few days. I am learning constructors with parameters. I was trying to run the following program in which I have declared two constructors, one without parameters and other with one parameter. The problem ... The program works perfectly when I comment out the error-generating statement. I have no idea what I am doing wrong. Please Help.
asked Nov 9, 2020 Code Learner 5.5k points
0 votes
1 answer 12 views
I noticed that in the loop of STATEMENT 1 we put (* p ++) and supposedly this represents that it is going to loop through an element of the array. But I start to think that the logical thing would be that if my pointer is starting at position [0]; in the loop of DECLARATION 1 I would start saving it in position ... position" << i << ":"; cin >> * p;         * p ++;     } * /          return 0; }
asked Aug 14, 2020 game 4.6k points
0 votes
1 answer 2 views
Problem: I want to iterate through each element in the map<string, int> without knowing any of its string-int values or keys. What I have so far: void output(map<string, int> table) { map<string, int>::iterator it; for (it = table.begin(); it != table.end(); it++) { //How do I access each element? } }
asked Dec 24, 2020 Mashhoodch 5.6k points
0 votes
1 answer 8 views
Problem: How do you find the length of a string? How do you find the length of a string without using strlen in C++? What is size of string in C++? Find length of string without using any library or built-in function like strlen() using strlen() function using Pointer
asked Dec 26, 2020 Mashhoodch 5.6k points
0 votes
2 answers 27 views
27 views asked Oct 17, 2020 SapperIt 1.2k points