• Register
1 vote
661 views

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 2 views
2 views
Problem Any idea when i use sizeof function in a class in c++
asked Mar 27 Subhendu 4.5k points
0 votes
1 answer 274 views
274 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 13k points
0 votes
1 answer 3 views
3 views
Problem Which function is batter way to find the size of a string in c++ size()/length(), Please anyone clear my confusion
asked 6 days ago Subhendu 4.5k points
0 votes
1 answer 97 views
97 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
1 vote
1 answer 4 views
4 views
Problem: What does this mean please make me understand on this. Get size of array c++.
asked Mar 24 PkGuy 13.1k points
0 votes
1 answer 4 views
4 views
Problem: Could anyone kindly assist me in resolving this uncaught error &ldquo;Find non repeating element in an array&rdquo;?
asked Mar 29 tuhin1 48.9k points
0 votes
1 answer 2 views
2 views
Problem: I'm having problems during my learning as I mentioned in my question above, I try to find on web search but I can't get proper information, can you help me to continue my project?
asked Mar 29 tuhin1 48.9k points
1 vote
1 answer 34 views
34 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 5 views
5 views
Problem: c++ array of objects initialization.
asked Mar 22 Dan phillip 4.8k points
0 votes
1 answer 20 views
20 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